#Does React JS Deploy also needs to run in 0.0.0.0 with the env port?
27 messages · Page 1 of 1 (latest)
N/A
what is the specific command in question?
Sorry, I was a little confused about how to deploy a React Application, so I've set the start command as "npm run build" and the start command(in deploy settings) as "npm run dev", and it went fine, but i've faced the 503 error when I tried to access the application by it's domain. Now(after create this post) i've just saw that the application crashed
whatever you do, you absolutely do not want to run a dev server on railway
and if you can avoid it (you can) you don't need to set any build and start commands in the service settings, so you can go and remove them
this looks like a csr rendered react app, so your build command should be building the static files into something like dist, and then your start command should be using serve to serve the static files
Oh! Thanks, Brody! I fixed it
care to share what you've learnt with the class?
Yeah! Sure. I just had to add an script to start the application with with a command-line static HTTP server. In my case, I've just add this script "start": "npx http-server ./dist", to be the start command in deploying settings. Now, i'm just a little confuse about the .htaccess file, because everytime that I reload the page, it reaches 404. I've saw that you don't use .htaccess file in rayway, in this case, you use nginx?
you'd want to use something suited to serve a react app like serve instead of http-server, like I previously mentioned
and there's no use of Apache or nginx on your service because you are doing a react app that uses a node based server
Oh! Ok. Sorry! Thank you, I think I've got u
there's also no need to set a start command in the service settings, you can just define them in your package.json
your start command should be serve dist -s -p $PORT
of course assuming vite builds into dist, your project might be setup differently
Thank you so much, Brody! It worked perfectly! I just used "start": "npx serve -s ./dist", instead of "start": "serve dist -s -p $PORT" because I was facing that serve by itself was not found
you're forgetting the port flag
Well, I didn't set any port and it worked
prob cuz you have a port set in your service variables
either way, you're not running a dev server anymore so you're good
Thank you ahahha. Today I've learned a lot. I'm a Junior developer and these stuffs involving deployment are still really complex for me
what does the -s do?