Can't GET non root "/" routes with Vite 4 in local production build (vite preview)
Describe the bug
After building a Vite 4 app with multiple routes, serving the build preview results in Cannot GET [route path] when accessing the route directly via URL (not using router Link / navigate)
Your Example Website or App
https://codesandbox.io/p/sandbox/router-vite-4-build-preview-404-hyw9p2?file=%2Fpackage.json&selection=%5B%7B%22endColumn%22%3A20%2C%22endLineNumber%22%3A22%2C%22startColumn%22%3A20%2C%22startLineNumber%22%3A22%7D%5D&workspace=%257B%2522activeFileId%2522%253A%2522cl9zkf3e9000alqiphi669wk8%2522%252C%2522openFiles%2522%253A%255B%2522%252Fpackage.json%2522%252C%2522%252Fsrc%252FApp.tsx%2522%255D%252C%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522gitSidebarPanel%2522%253A%2522COMMIT%2522%252C%2522spaces%2522%253A%257B%2522clbgz73pt000u2e68tr18odty%2522%253A%257B%2522key%2522%253A%2522clbgz73pt000u2e68tr18odty%2522%252C%2522name%2522%253A%2522Default%2522%252C%2522devtools%2522%253A%255B%257B%2522type%2522%253A%2522PREVIEW%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A5173%252C%2522key%2522%253A%2522clbh09t4x06ya2e68ayopemcq%2522%252C%2522isMinimized%2522%253Afalse%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522key%2522%253A%2522clbh09k5a06u62e68g8pkqjkx%2522%252C%2522isMinimized%2522%253Afalse%257D%255D%257D%257D%252C%2522currentSpace%2522%253A%2522clbgz73pt000u2e68tr18odty%2522%252C%2522spacesOrder%2522%253A%255B%2522clbgz73pt000u2e68tr18odty%2522%255D%257D
Steps to Reproduce the Bug or Issue
- Go to sandbox
- Run
buildcommand - Run
previewcommand - Open the
previewwindow in a separate tab - Navigate to
/params/list - Reload the page to get the behaviour
- See the error
Warning Cannot GET "/param/list"
Screen-cast of the process
I've attached a screen-cast of the process on how to reproduce the behaviour via the provided codesanbox
Expected behavior
I expect all routes to be defined and accessible in production build of the app
Screenshots or Videos
https://user-images.githubusercontent.com/16290753/206797595-2d2cf656-e036-4a17-bf15-22b17b3dd8d4.mp4
Platform
- OS: macOS
- Browser: Firefox
- Version: 108.0b9
Additional context
I'm not sure if it's primarily a TS Router bundling issue or a Vite 4 one