-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite/spa: npm run start
using http-server does not support SPA routes
#8623
Comments
I'm a bit torn here 🤔 Yes - Remix SPA mode is built to allow you to load/hydrate any path on initial load. So in theory you're correct that when testing the prod build it should also allow that. However, I don't love encouraging testing the prod build via something that does not match what you will actually use in prod (since For example, would it be a potential footgun for folks to run It almost seems potentially safer to use something that aligns with the lowest common denominator of deploy modes (i.e., something like I dunno - maybe this is all a non-issue - if vite's decided that |
@brophdawg11 Thanks for looking into this. I agree that this command isn't production ready, but neither is any other simple option without going back to a
This is why my proposed solution is to drop the |
A patch is needed to get I mentioned a something closer to production-ready in the updated Lines 37 to 41 in d222686
However, I wouldn't want someone to think that is the best solution either when Vite has nice documentation on deploying a static/SPA site and it might be worth linking to: https://vitejs.dev/guide/static-deploy.html Edit: The Vite guide may be too general if it includes multi-page outputs from Vite. I don't think linking to it without checking is ideal. For example, as far as I am aware, GitHub pages doesn't directly support the path re-writing to |
ok yeah I think I can get on board with removing any opinions about how to deploy to production and just linking to Vite's docs there and main that apparent in the docs/template. I'll take a look over the PR when I have a moment 👍 |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Reproduction
Run this script (PowerShell):
Open browser directly to http://127.0.0.1:8080/hello (change port if needed). Also try reloading the browser (
F5
) after navigating to the/hello
route from the root (/
) path.System Info
Used Package Manager
npm
Expected Behavior
When previewing a build, the server should support SPA fallback mode (serving multiple paths from a single
index.html
file) when using the SPA template. Usevite preview
orsirv-cli --single
as alternatives. (vite preview
is powered bysirv
).No simple solutions that I found are especially production ready as they don't set the
cache-control
header for./assets
files separately from other files.Actual Behavior
Navigating directly to a sub-route such as http://127.0.0.1:8080/hello fails with an HTTP ERROR 404.
Navigating to the page when starting at http://127.0.0.1:8080/ works correctly, but reloading once navigated to http://127.0.0.1:8080/hello also fails with an HTTP ERROR 404.
http-server
does not support SPA mode. (it has been much discussed, but left unresolved, see http-party/http-server#772).The text was updated successfully, but these errors were encountered: