Issue with 404 showing on page reload

kingsley-anokam
PROOP

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

Solved$10 Bounty

2 Replies

Railway
BOT

24 days ago


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


pauldps
HOBBY

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.html

Try replacing that line with this:

try_files {path} /index.html

This should work for any deeply nested routes.

Hope that helps.


Status changed to Solved kingsley-anokam 23 days ago


Loading...
Issue with 404 showing on page reload - Railway Help Station