R
Railway•12mo ago
NariDuke

React 404 page

I have a react/django project, locally it runs fine with serve, when deploying it on firebase it worked, now on railway it deploys without an error, but i get a 404 page whatever url/path i try. I use a dockerfile and i have modified my package.json with a guide you posted for common issues when deploying react apps.
No description
95 Replies
Percy
Percy•12mo ago
Project ID: 12561993-57a7-47ee-a585-f6bb61a5f346
NariDuke
NariDukeOP•12mo ago
12561993-57a7-47ee-a585-f6bb61a5f346
Brody
Brody•12mo ago
react frontend, django backend, in a monorepo?
NariDuke
NariDukeOP•12mo ago
yes but we have 2 braches for deployments one for django one for react 2482d13c-5d1b-4e11-ada9-297b738fa18a service id for the react deploy
Brody
Brody•12mo ago
branches? do you mean services?
NariDuke
NariDukeOP•12mo ago
both? we have 2 services 64b69db4-62d6-4f9c-9cf7-724a3d8cec5c here the django service
Brody
Brody•12mo ago
(i dont work for railway, these ids dont help me with anything)
NariDuke
NariDukeOP•12mo ago
srry mb
Brody
Brody•12mo ago
so instead, can i see a screenshot of your project
NariDuke
NariDukeOP•12mo ago
yeah sure dont you prefer the github repo?
Brody
Brody•12mo ago
id actually like both a screenshot and the repo if you dont mind?
NariDuke
NariDukeOP•12mo ago
sure
NariDuke
NariDukeOP•12mo ago
GitHub
GitHub - tomasguell/FATG2-2023-VILLADA: Proyecto Final, en busqueda...
Proyecto Final, en busqueda de desarrollar un sistema necesitado por una ong, que no tenga los recursos para afordarlo. - GitHub - tomasguell/FATG2-2023-VILLADA: Proyecto Final, en busqueda de desa...
Brody
Brody•12mo ago
screenshot please?
NariDuke
NariDukeOP•12mo ago
give me a moment ok srry for the long wait
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
login
Brody
Brody•12mo ago
sorry i should have been more clear, i wanted a screenshot of the railway project
NariDuke
NariDukeOP•12mo ago
oh that makes more sense lol
Brody
Brody•12mo ago
haha yeah mb
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
the two with green checks are the back and fronty
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
No description
Brody
Brody•12mo ago
have you set root directories on the backend and frontend services?
NariDuke
NariDukeOP•12mo ago
in the dockerfiles, yes in railway idk where they are ok found nope just a single slash as root folder
Brody
Brody•12mo ago
can you send me the build table at the top of the build logs for front and backend services?
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
front
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
back
Brody
Brody•12mo ago
you have non standard dockerfile names, how have you told railway to use them?
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
both of them have this with the proper path to their own dockerfile
Brody
Brody•12mo ago
did you say your backend service was working fine?
NariDuke
NariDukeOP•12mo ago
yes wanna login? XD
Brody
Brody•12mo ago
okay cool, but i just want to note that you are running the backend in development mode with runserver, please look into using gunicorn going forward as for the frontend, you have issues with peer deps right?
NariDuke
NariDukeOP•12mo ago
No description
NariDuke
NariDukeOP•12mo ago
i am using gunicorn yes
NariDuke
NariDukeOP•12mo ago
ow i se
Brody
Brody•12mo ago
haha that wouldnt cause issues with 404, just wanted to make sure thats why you where using --force
NariDuke
NariDukeOP•12mo ago
aahaha ok
Brody
Brody•12mo ago
where are you setting the serve start command for the frontend?
NariDuke
NariDukeOP•12mo ago
package.json
Brody
Brody•12mo ago
am i looking at the wrong github branch?
NariDuke
NariDukeOP•12mo ago
ohhh
NariDuke
NariDukeOP•12mo ago
yes
Brody
Brody•12mo ago
what branch should i be looking at
NariDuke
NariDukeOP•12mo ago
remember that i said i we had 2 braches for deployments? this is what i meant
Brody
Brody•12mo ago
right, but what one should i be looking at? you sent me to the main branch again
NariDuke
NariDukeOP•12mo ago
bruh mb again PythonMainDeploy and ReactMainDeploy
NariDuke
NariDukeOP•12mo ago
GitHub
GitHub - tomasguell/FATG2-2023-VILLADA at PythonMainDeploy
Proyecto Final, en busqueda de desarrollar un sistema necesitado por una ong, que no tenga los recursos para afordarlo. - GitHub - tomasguell/FATG2-2023-VILLADA at PythonMainDeploy
NariDuke
NariDukeOP•12mo ago
GitHub
GitHub - tomasguell/FATG2-2023-VILLADA at ReactMainDeploy
Proyecto Final, en busqueda de desarrollar un sistema necesitado por una ong, que no tenga los recursos para afordarlo. - GitHub - tomasguell/FATG2-2023-VILLADA at ReactMainDeploy
Brody
Brody•12mo ago
oh this is certainly an odd way of doing this
NariDuke
NariDukeOP•12mo ago
yes its a mess
Brody
Brody•12mo ago
haha your words not mine looking into it though
NariDuke
NariDukeOP•12mo ago
dont look at the commit tags chill
Brody
Brody•12mo ago
do you use the dockerfile locally too?
NariDuke
NariDukeOP•12mo ago
yup
Brody
Brody•12mo ago
mind if i do a little re-write? (on the dockerfile)
NariDuke
NariDukeOP•12mo ago
nah
Brody
Brody•12mo ago
on it 🫡
NariDuke
NariDukeOP•12mo ago
take all the time you need
Brody
Brody•12mo ago
any idea why id be getting this error?
9.436 Failed to compile.
9.436
9.437 Module not found: Error: Can't resolve 'simple-zustand-devtools' in '/frontend/src/store'
9.436 Failed to compile.
9.436
9.437 Module not found: Error: Can't resolve 'simple-zustand-devtools' in '/frontend/src/store'
NariDuke
NariDukeOP•12mo ago
Not really
Brody
Brody•12mo ago
moving simple-zustand-devtools from devDependencies to dependencies removed this error
NariDuke
NariDukeOP•12mo ago
Ok Dude You still on this? Im feeling bad for you
Brody
Brody•12mo ago
yeah, railway went down for a bit during this
Brody
Brody•12mo ago
instead of serve we now use caddy so you will need to add this Caddyfile to your project
Brody
Brody•12mo ago
and this is the new Dockerfile with a capital D so that railway will auto detect it
NariDuke
NariDukeOP•12mo ago
No way Dude Luv u
Brody
Brody•12mo ago
(the lowercase d was not the issue)
NariDuke
NariDukeOP•12mo ago
NOOO??? Really?
Brody
Brody•12mo ago
no it wasnt, you wernt running npm run build but simply sticking that command in your dockerfile wasnt good enough for me this multistage dockerfile generates a ~45mb image and uses caddy, caddy uses far less memory then serve and is far more configurable you'll need to do this, or sort out a proper solution
NariDuke
NariDukeOP•12mo ago
im prob sticking to your solution
Brody
Brody•12mo ago
fair enough i regret to inform you that the Caddyfile / Dockerfile combo i gave you didnt work, it did at one point, i am fixing this
NariDuke
NariDukeOP•12mo ago
ok im gettin this error even followin your solution idk if its the same error that youre going thru rn
Brody
Brody•12mo ago
i also regened the lock file, sorry should have mentioned that im getting 404 with caddy lol
NariDuke
NariDukeOP•12mo ago
lol
Brody
Brody•12mo ago
your frontend sure takes a long time to build
NariDuke
NariDukeOP•12mo ago
yeah, i get it i will send a ticket to the frontend dev team lol
Brody
Brody•12mo ago
fingers crossed, i think i have it this time, i forgot how COPY works 🤣
NariDuke
NariDukeOP•12mo ago
dsb g jkvs
Brody
Brody•12mo ago
new Dockerfile works and heres proof this time https://test-service1.up.railway.app/
NariDuke
NariDukeOP•12mo ago
omfg it actually works
Brody
Brody•12mo ago
haha yep
NariDuke
NariDukeOP•12mo ago
youre my savior
Brody
Brody•12mo ago
right now mem is sitting at 20mb!
NariDuke
NariDukeOP•12mo ago
forgot to thank u 4 that is really impresive i just know the most basic things of docker and sht and u litterally do wonders
Brody
Brody•12mo ago
i forgot how COPY works, im not all that good myself
NariDuke
NariDukeOP•12mo ago
do u think i know how copy works?
Brody
Brody•12mo ago
fair enough this dockerfile has less layers, and i promise it still works
Brody
Brody•12mo ago
Want results from more Discord servers?
Add your server