Vite base and Router basepath problems when deploying
Hello,
I have a React 19 (experimental) with Vite (6.3.1) and Tanstack Router (1.121.0-alpha.22) project with a basepath /ui set in both vite.config.ts and createRouter. Everything works fine in dev, but when deploying to Nomad i get the following error:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
I also get ERR_ABORTED 404 (Not Found) on the index.js and index.css files when trying npx serve on the build folder going to localhost:3000. Navigating to localhost:3000/ui i get 404 (Not Found) on the page.
However, removing both base from vite.config.ts and basepath from createRouter it works fine with npx serve on localhost:3000, but it doesn't work in production because it tries to fetch the assets from example.com instead of example.com/ui.
Any help would be appreciated!
2 Replies
rising-crimsonOP•3mo ago
P.S. I get the same result locally when trying out the "basic-react-query-file-based" with a base set to /ui in vite.config and createRouter with npx serve.
foreign-sapphire•3mo ago
can you please create a github issue for this including a complete minimal example?