R
Railway•7mo 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•7mo ago
Project ID: 12561993-57a7-47ee-a585-f6bb61a5f346
NariDuke
NariDuke•7mo ago
12561993-57a7-47ee-a585-f6bb61a5f346
Brody
Brody•7mo ago
react frontend, django backend, in a monorepo?
NariDuke
NariDuke•7mo 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•7mo ago
branches? do you mean services?
NariDuke
NariDuke•7mo ago
both? we have 2 services 64b69db4-62d6-4f9c-9cf7-724a3d8cec5c here the django service
Brody
Brody•7mo ago
(i dont work for railway, these ids dont help me with anything)
NariDuke
NariDuke•7mo ago
srry mb
Brody
Brody•7mo ago
so instead, can i see a screenshot of your project
NariDuke
NariDuke•7mo ago
yeah sure dont you prefer the github repo?
Brody
Brody•7mo ago
id actually like both a screenshot and the repo if you dont mind?
NariDuke
NariDuke•7mo ago
sure
NariDuke
NariDuke•7mo 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•7mo ago
screenshot please?
NariDuke
NariDuke•7mo ago
give me a moment ok srry for the long wait
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
login
Brody
Brody•7mo ago
sorry i should have been more clear, i wanted a screenshot of the railway project
NariDuke
NariDuke•7mo ago
oh that makes more sense lol
Brody
Brody•7mo ago
haha yeah mb
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
the two with green checks are the back and fronty
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
No description
Brody
Brody•7mo ago
have you set root directories on the backend and frontend services?
NariDuke
NariDuke•7mo ago
in the dockerfiles, yes in railway idk where they are ok found nope just a single slash as root folder
Brody
Brody•7mo ago
can you send me the build table at the top of the build logs for front and backend services?
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
front
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
back
Brody
Brody•7mo ago
you have non standard dockerfile names, how have you told railway to use them?
NariDuke
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
both of them have this with the proper path to their own dockerfile
Brody
Brody•7mo ago
did you say your backend service was working fine?
NariDuke
NariDuke•7mo ago
yes wanna login? XD
Brody
Brody•7mo 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
NariDuke•7mo ago
No description
NariDuke
NariDuke•7mo ago
i am using gunicorn yes
NariDuke
NariDuke•7mo ago
ow i se
Brody
Brody•7mo ago
haha that wouldnt cause issues with 404, just wanted to make sure thats why you where using --force
NariDuke
NariDuke•7mo ago
aahaha ok
Brody
Brody•7mo ago
where are you setting the serve start command for the frontend?
NariDuke
NariDuke•7mo ago
package.json
Brody
Brody•7mo ago
am i looking at the wrong github branch?
NariDuke
NariDuke•7mo ago
ohhh
NariDuke
NariDuke•7mo ago
yes
Brody
Brody•7mo ago
what branch should i be looking at
NariDuke
NariDuke•7mo ago
remember that i said i we had 2 braches for deployments? this is what i meant
Brody
Brody•7mo ago
right, but what one should i be looking at? you sent me to the main branch again
NariDuke
NariDuke•7mo ago
bruh mb again PythonMainDeploy and ReactMainDeploy
NariDuke
NariDuke•7mo 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
NariDuke•7mo 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•7mo ago
oh this is certainly an odd way of doing this
NariDuke
NariDuke•7mo ago
yes its a mess
Brody
Brody•7mo ago
haha your words not mine looking into it though
NariDuke
NariDuke•7mo ago
dont look at the commit tags chill
Brody
Brody•7mo ago
do you use the dockerfile locally too?
NariDuke
NariDuke•7mo ago
yup
Brody
Brody•7mo ago
mind if i do a little re-write? (on the dockerfile)
NariDuke
NariDuke•7mo ago
nah
Brody
Brody•7mo ago
on it 🫡
NariDuke
NariDuke•7mo ago
take all the time you need
Brody
Brody•7mo 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
NariDuke•7mo ago
Not really
Brody
Brody•7mo ago
moving simple-zustand-devtools from devDependencies to dependencies removed this error
NariDuke
NariDuke•7mo ago
Ok Dude You still on this? Im feeling bad for you
Brody
Brody•7mo ago
yeah, railway went down for a bit during this
Brody
Brody•7mo ago
instead of serve we now use caddy so you will need to add this Caddyfile to your project
Brody
Brody•7mo ago
and this is the new Dockerfile with a capital D so that railway will auto detect it
NariDuke
NariDuke•7mo ago
No way Dude Luv u
Brody
Brody•7mo ago
(the lowercase d was not the issue)
NariDuke
NariDuke•7mo ago
NOOO??? Really?
Brody
Brody•7mo 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
NariDuke•7mo ago
im prob sticking to your solution
Brody
Brody•7mo 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
NariDuke•7mo ago
ok im gettin this error even followin your solution idk if its the same error that youre going thru rn
Brody
Brody•7mo ago
i also regened the lock file, sorry should have mentioned that im getting 404 with caddy lol
NariDuke
NariDuke•7mo ago
lol
Brody
Brody•7mo ago
your frontend sure takes a long time to build
NariDuke
NariDuke•7mo ago
yeah, i get it i will send a ticket to the frontend dev team lol
Brody
Brody•7mo ago
fingers crossed, i think i have it this time, i forgot how COPY works 🤣
NariDuke
NariDuke•7mo ago
dsb g jkvs
Brody
Brody•7mo ago
new Dockerfile works and heres proof this time https://test-service1.up.railway.app/
NariDuke
NariDuke•7mo ago
omfg it actually works
Brody
Brody•7mo ago
haha yep
NariDuke
NariDuke•7mo ago
youre my savior
Brody
Brody•7mo ago
right now mem is sitting at 20mb!
NariDuke
NariDuke•7mo 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•7mo ago
i forgot how COPY works, im not all that good myself
NariDuke
NariDuke•7mo ago
do u think i know how copy works?
Brody
Brody•7mo ago
fair enough this dockerfile has less layers, and i promise it still works
Brody
Brody•7mo ago