T
TanStack•3y ago
conscious-sapphire

page not found when going directly to a route when deployed on netlify

Hello everyone! I'm having some issues, when I navigate through the app normally I can reach any route. Like clicking a <Link> that redirects to /app However when i try to go directly to let's say https://example.com/app I get Page Not Found. This doesnt happen locally on development. Anyone what may be happening?
No description
7 Replies
frail-apricot
frail-apricot•3y ago
Can we get a link to the repo?
sunny-green
sunny-green•3y ago
This looks like a netlify thing. In the project, in the netlify.toml you can add the following
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
Basically since its a SPA (single page application), you need to tell Netlify to silently redirect all traffic to your index.html From there on, the router takes over.
conscious-sapphire
conscious-sapphireOP•3y ago
this worked perfectly. thanks @Sean Cassiere 🙌 should this be added to documentation @Tanner Linsley i can add if you want
frail-apricot
frail-apricot•3y ago
That would be great!
conscious-sapphire
conscious-sapphireOP•3y ago
which section should it go? made my first contribution yesterday - https://github.com/TanStack/router/pull/498 this library is so great, thank you for all your work tanner. eventhough it's still on beta i'm already using it for the next big product of https://openbb.co alongside @tanstact/virtual, @tanstact/query and @tanstact/table 😄
frail-apricot
frail-apricot•3y ago
Woo! Just put it where you see fit for now I'll organize it when I start writing the rest of the docs
sunny-green
sunny-green•3y ago
Since this trick is cloud vendor specific (i.e. Netlify), maybe include a link to their docs. https://docs.netlify.com/configure-builds/file-based-configuration/#redirects
File-based configuration
Use a netlify.toml configuration file to specify how the platform builds and deploys your project.

Did you find this page helpful?