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
eastern-cyan•11mo ago
is this just for local dev usage?
extended-salmonOP•11mo ago
Also built
eastern-cyan•11mo ago
you wouldnt use vite in prod anyhow
extended-salmonOP•11mo ago
yes
eastern-cyan•11mo ago
so you need to configure your webserver correctly
extended-salmonOP•11mo ago
I don't have the vite plugin
I am using the cli
eastern-cyan•11mo ago
so that it always serves index.html
extended-salmonOP•11mo ago
Yup, i was wondering how do i get the routes without doing ti manually
Can i use the cli?
eastern-cyan•11mo ago
which cli
extended-salmonOP•11mo ago
"@tanstack/router-cli
eastern-cyan•11mo ago
what for
extended-salmonOP•11mo ago
to add automatically to the static all the routes of the spa
like this works
eastern-cyan•11mo ago
are you really using bun in production to serve your app? or is this only on your local machine
extended-salmonOP•11mo ago
Yes
Prod
Can I parse the routeTree somehow?
eastern-cyan•11mo ago
sounds super backwards to me
you want your http server to always serve the index.html regardless which path is accessed
extended-salmonOP•11mo ago
wdym? They just added the bundler https://bun.sh/blog/bun-v1.2#bun-is-a-javascript-bundler
eastern-cyan•11mo ago
otherwise you cant handle not founds with router
extended-salmonOP•11mo ago
and in my index.html i point to a react file
Literally what vite does