dist/Index.html shows route not found after vite build in dist folder
Hi after i run vite build, and try to load index.html with live server, the __root folder will load properly with all the components(including outlet component), however outlet component will just show the defaultNotFoundComponent defined in the createRouter, if i set the defaultNotFoundComponent as a <Link/> element to other routes, it will load the route properly. what should i do to get the outlet to load the route properly when the webpage first loads from index.html?
the defaultNotFoundComponent, the Link works perfectly to load the route:


5 Replies
rival-blackOP•16mo ago
Under the routes folder i also have index.tsx which has the '/' route, which is what i want the outlet to first load, but it shows defaultNotFoundComponent instead

ratty-blush•16mo ago
please provide a minimal complete example by forking on of the existing examples on stackblitz
rival-blackOP•16mo ago
https://stackblitz.com/edit/vitejs-vite-tesdvu?file=src%2Fmain.tsx
I replicated the dev code on stackblitz, dev mode works fine, but when i do 'npm run build' on vscode and then open the dist/index.html with vscode live server, it will show the route not found component unless i provide a way to link to another page inside notfoundComponent, to replicate you will have to download it into vscode and do npm run build and open the dist/index.html with liveserver
Also this is probably a problem with vite but under dist/index.html after you do npm run build, make sure the script source is src="./assets/index-CCcrIDlY.js" instead of src="/assets/index-CCcrIDlY.js" , if there is no period at the front the file wont load.
ratty-blush•16mo ago
why do you even use vscode liveserver instead of vite server?
rival-blackOP•16mo ago
I use vite server for dev mode, was testing out the dist/index.html with live server, i tried it with vite server for dist/index.html too but it has the same RouteNotFound on initial load