-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[Bug]: v7pre - Can't use vite preview with SPA + basename + prerender #12083
Comments
For now I've solved it adding this plugin to vite config, but it doesn't seem very clean {
name: "configure-preview-server",
configurePreviewServer(server) {
return () => {
server.middlewares.use((req, res, next) => {
if (req.url === "/index.html") {
req.url = `${req.originalUrl?.slice(0, -1)}${req.url}`;
}
next();
});
};
}
} |
I'm not quite sure what to do here - with But then when Vite's I think |
It does work but scripts will have |
I think we have a check somewhere that I'll see if I can find some time to play around with these combinations and see if there's a good solution that works for all cases. |
It's worth mentioning that Vite allows using |
@brophdawg11 I think this assumption might be incorrect? The base name is often used for deploying to a sub-directory that already exists. This is the case with GitHub Pages, where you are basically forced to use a sub-path, even if you deploy to the root. Currently, using Maybe unrelated: I also noticed a strange issue after deploying the |
What version of React Router are you using?
7.0.0-pre.0
Steps to Reproduce
ssr: false
)npm run build
vite preview
.Minimal reproduction (run
npm run build
+npm run preview
on it):https://stackblitz.com/edit/react-router-v7-basename-prerender-preview?file=vite.config.ts
Expected Behavior
When opening http://localhost:4173/chat/, the preview server responds with /build/client/chat/index.html and the root route is rendered.
Actual Behavior
There is a 404 error response.
When opening http://localhost:4173/chat/, vite tries to respond with the file /build/client/index.html which doesn't exist (the prerendered route is in /build/client/chat/index.html), so there is a 404 response.
The text was updated successfully, but these errors were encountered: