Properly document our client deployment #1982
Labels
deployment
documentation
Improvements or additions to documentation
enhancement
New feature or request
shouldfix
We should do/fix this at some point
In production, our client is just a bunch of static files. When you input a non-existent file path into the address bar (or the browser tries to redirect to it), the navigation fails with a 404 - no surprises there.
You can see this behavior by serving the client files locally and trying to access http://localhost:3000/login directly from the address bar.
Therefore: for Wasp client deployments to work, the server that's serving the static files must return
index.html
for all extension-less paths (regardless of the path requested by the browser).This way, the static server delegates all routing to the React Router on the frontend, which then knows what to do. The extension-less part is important because we still want to properly serve all other static resources (CSS, HTML, JS, images, etc.)
To solve this problem on Fly.io, we've configured our Go server to fall back onto
index.html
for all non-existent paths:What needs to be done:
fallback
is the best option - Fallback means "returnindex.html
when you can't find the requested path on disk. What we truly want is "returnindex.html
for all paths without an extension." A possible edge case wherefallback
becomes problematic is a user-defined route that accidentally resolves to an existing extension-less file on disk (unlikely). Fallback might also have implications on response status codes.index.html
. Perhaps we should include examples.Easy solutions:
npx serve -s
- the-s
or--single
flag is meant for serving single page apps. The--help
command says for the flag: Rewrite all not-found requests toindex.html
.Note
Since our docs don't mention this problem at all, and many user deploy the frontend on their own (without using Fly.io), how come we haven't heard any complaints? Are most servers configured to fall back onto
index.html
by default? Or are they hitting the issue and giving up?The text was updated successfully, but these errors were encountered: