Redirect routing to correct route from bun
I am using the new bun 1.2 to bundle my SPA and so far everything is working great! I only have a small issue which I am sure as been addressed before but I couldn't find. Basically with the new bun 1.2 it allows you bundle the app without the need of vite here's the code
now the thing is i have two routes / and /login. When I navigate to /login with the link component from the router it works fine as I would expect it to, but when I land to localhost:3000/login obviously it doesn't work as it's not bundling the app there. Any suggestions on where I can read more / find a possible solution to this?
18 Replies
yappiest-sapphire•8mo ago
is this just for local dev usage?
rare-sapphireOP•8mo ago
Also built
yappiest-sapphire•8mo ago
you wouldnt use vite in prod anyhow
rare-sapphireOP•8mo ago
yes
yappiest-sapphire•8mo ago
so you need to configure your webserver correctly
rare-sapphireOP•8mo ago
I don't have the vite plugin
I am using the cli
yappiest-sapphire•8mo ago
so that it always serves index.html
rare-sapphireOP•8mo ago
Yup, i was wondering how do i get the routes without doing ti manually
Can i use the cli?
yappiest-sapphire•8mo ago
which cli
rare-sapphireOP•8mo ago
"@tanstack/router-cli
yappiest-sapphire•8mo ago
what for
rare-sapphireOP•8mo ago
to add automatically to the static all the routes of the spa
like this works
yappiest-sapphire•8mo ago
are you really using bun in production to serve your app? or is this only on your local machine
rare-sapphireOP•8mo ago
Yes
Prod
Can I parse the routeTree somehow?
yappiest-sapphire•8mo ago
sounds super backwards to me
you want your http server to always serve the index.html regardless which path is accessed
rare-sapphireOP•8mo ago
wdym? They just added the bundler https://bun.sh/blog/bun-v1.2#bun-is-a-javascript-bundler
yappiest-sapphire•8mo ago
otherwise you cant handle not founds with router
rare-sapphireOP•8mo ago
and in my index.html i point to a react file
Literally what vite does