24 days ago
On page reload, the project routes to the 404 page
This happens with deep routing.
Project was developed using Vite React, hosted using Docker and CaddyFile.
Please find attached the caddyFile
Attachments
2 Replies
24 days ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Vite: On Live Server, Fix React Router Page 404 on Refresh
🧵 Has anyone had an issues with .well-known/ files not showing up properly in their railway builds?
If you find the answer from one of these, please let us know by solving the thread!
24 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 24 days ago
24 days ago
This is happening because when you refresh the page on a deep route, the static file for that route is not found on the server.
Your SPA is only serving a index.html file, so you need a rewrite rule that will "forward" any non-existing hard files (aka your routes) back to index.html, so that client-side routing can happen.
In your Caddyfile you have:
try_files {path} {path}.html {path}/index.html /index.htmlTry replacing that line with this:
try_files {path} /index.htmlThis should work for any deeply nested routes.
Hope that helps.
Status changed to Solved kingsley-anokam • 23 days ago