I am attempting to configure a static app on azure and am struggling to route correctly. When I navigate to /lti/login/
within the app it works fine. But if I refresh it throws a 404, which tells me that my routes.json
isn't setup correctly (maybe). I am hoping someone can shine some light on this.
routes.json
{
"routes": [
{
"route": "/",
"serve":"/"
},
{
"route": "/lti/login/*",
"serve":"/lti/login"
}
]
}
App.js
<Router>
<div>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/lti/login/">About</Link>
</li>
</ul>
<hr />
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>
<Route exact path="/">
<Form />
</Route>
<Route path="/lti/login/*"> <----- If I navigate to this within the app and then refresh it throws a 404.
<About />
</Route>
</Switch>
</div>
</Router>
As for the latest documentation the use of routes is deprecated:
now you need to add navigationFallback section in staticwebapp.config.json like so:
you can find the full documentation here:
https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#fallback-routes