R
Railway9mo ago
meeka33

react 404

my react app works on local host and it works when deployed so if i click onto one of the pages it works but if i refresh that page it just breaks and sends a 404 also if i where to search example.com/faq i will be shown 404 as well
Solution:
heres an example repo https://github.com/brody192/create-react-app-starter dont seperate the build folder out into another repo. copy the nixpacks.toml and Caddyfile from my repo into your project repo and deploy the project repo instead...
Jump to solution
23 Replies
Percy
Percy9mo ago
Project ID: N/A
Brody
Brody9mo ago
please share your repo
maddsua
maddsua9mo ago
classic: no redirect is set up for client side routing
Brody
Brody9mo ago
theres something odd going on though, if they where using a dev server the /fag page would work
maddsua
maddsua9mo ago
doesn't a static "thingy" on railway need it to be configured separately? if I just build a vite+react project and put it as is it would behave the same
Brody
Brody9mo ago
if you uploaded just the build folder yes
maddsua
maddsua9mo ago
well they didn't say "a next app" so I assume a static build ok not gonna argue
Brody
Brody9mo ago
yeah but they are likely uploading the entire project folder, package.json and all. theres too many unknowns, thats why i asked for the repo
meeka33
meeka339mo ago
Sorry I just went out for food so I’m afk but I’m not using vite and I just pulled the build into its own repo and then deployed that
Brody
Brody9mo ago
create react app?
meeka33
meeka339mo ago
Yep
Solution
Brody
Brody9mo ago
heres an example repo https://github.com/brody192/create-react-app-starter dont seperate the build folder out into another repo. copy the nixpacks.toml and Caddyfile from my repo into your project repo and deploy the project repo instead
meeka33
meeka339mo ago
The reason I pulled the build folder was when I deployed it, the react dev tools was red meaning that it wasn’t correct and the usage was crazy
Brody
Brody9mo ago
because you where running a development server
meeka33
meeka339mo ago
Yh how do I not do that😂😂
Brody
Brody9mo ago
see my message above
meeka33
meeka339mo ago
This
Brody
Brody9mo ago
yeah, read the readme for further info
meeka33
meeka339mo ago
Thank you will try when I get back brody you the goat, 3 months ago i had my head spun because i was just uploading my full repo and it took 2 days & 3 compsi students to figuire out how to deploy a react app that didn't have stupid usage and i just spent the whole day looking at other people's tickets in the help section and this literally worked first time no problems
Brody
Brody9mo ago
happy i could help railway is not like vercel, railway runs your code as is and uses the default start script, if the start script starts a development server, then a development server is what will be ran
meeka33
meeka339mo ago
ah i see, can you give me a better understanding of deploying react apps im self taught no one around me not even my friends that are juniors could explain how react works when deploying like what's the industry norm of deploying a react app and is there a difference of deploying a react vite app?
Brody
Brody9mo ago
neither create react app or vite come with production ready web servers, thats where caddy comes into play. as mentioned railway is not like vercel so we have to setup the web server ourselves (caddy) but i have never built a site with react or any framework for that matter, so im no help with that side of things, i only know how to deploy them
meeka33
meeka339mo ago
ohhhhhh okay i see thank you very much
Want results from more Discord servers?
Add your server