Recently I have come across am issue with the non-existent routes redirect, since I use React router with BrowserRouter the react app has a page for some paths, but those paths don’t have an index.html file, and creating an index.html for each page can quickly become tiring and a mess, and for apps that has dynamic paths, like https://example.glitch.me/f/112 it isn’t possible to do using simple browser router.
So the idea is have a toggle for the redirect, leaving the handling of 404 to the project, but without affecting existing Generated Satic projects
Hi @Awakened-Redstone would you mind confirming that the technique here doesn’t work for you?
For example if I remix the current Glitch Hello React starter project and add the changes in this tutorial any non existent route returns the Not Found page:
However I’m not sure if this works with however you’re generating your dynamic paths / using browser router etc. Let me know if you still can’t get the behavior you need!
On my site I have a 404 route, but it is never shown when on production mode since it gets redirected to root path. On development mode, since it doesn’t redirect, it does show the 404 page
OK so it sounds like it would be problematic to provide a toggle for the redirecting but hopefully we can figure out how to create the behavior you’re looking for within your project. Can you provide a little more detail about why you have your routing setup the way you do / what the end result you’re looking for is?