Skip to content

Commit

Permalink
Fix 404 redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
1-max-1 committed Jan 17, 2023
1 parent 58df92a commit 929271f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 6 additions & 3 deletions WASMSerialTerminal/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<Router AppAssembly="@typeof(App).Assembly">
@inject NavigationManager NavManager

<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
@* If the web serial API is supported, then we can render the regular content *@
<WebSerialSupportChecker>
Expand All @@ -7,9 +9,10 @@
</WebSerialSupportChecker>
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
@{ NavManager.NavigateTo("", false, true); }
<PageTitle>WASM Serial Terminal</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
<p role="alert">Sorry, there's nothing at this address. Redirecting you to the main page...</p>
</LayoutView>
</NotFound>
</Router>
21 changes: 11 additions & 10 deletions WASMSerialTerminal/wwwroot/404.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>WASM Serial Terminal</title>
<!-- If the user has put in extra junk on the URL, clear it and redirect users to the app page. For github pages only. -->
<script type="text/javascript">
window.location = window.location.split("/").slice(0, 4);
</script>
</head>
<body>
</body>
<head>
<meta charset="utf-8" />
<title>WASM Serial Terminal</title>
<!-- If the user has put extra junk on the URL, clear it and redirect them to the app page. For github pages first request. -->
<!-- Redirects are also handled by App.razor if 404.html isn't reached -->
<script type="text/javascript">
window.location = window.location.toString().split("/").slice(0, 4).join("/");
</script>
</head>
<body>
</body>
</html>

0 comments on commit 929271f

Please sign in to comment.