Hosting React frontend with Express backend
Need assistance with hosting a very simple site, not sure what I'm missing. Works fine as localhost but live is acting differently.
53 Replies
Project ID:
c498f886-3455-4e56-9532-44c33c627d59
What are your logs? Also, please do provide your project ID, in case somebody with platform access comes along.
c498f886-3455-4e56-9532-44c33c627d59
You might find these helpful:
- Application URL disappeared in dashboard after deployment of backend server app
- Hosting Existing Postgress database
- Mern App works locally, but not when deployed
⚠️ experimental feature
I'm assuming it built?
This is the backend index
Idk if im doing something wrong or not
never tried react before
Could you send the deploy logs? (and please actually send the logs, not a screenshot)
Doesn't show any deploy logs
Also, for full-stack React I'd recommend Next.js (https://nextjs.org) or Remix (https://remix.run), as those support TypeScript better and are likely to be generally nicer and significantly faster than an Express backend.
Next.js by Vercel - The React Framework for the Web
Used by some of the world's largest companies, Next.js enables you to create full-stack Web applications by extending the latest React features, and integrating powerful Rust-based JavaScript tooling for the fastest builds.
That's odd.
Aye, im not sure
Oh, it's working fine.
Your app
is working
https://test-react-production.up.railway.app/api
hm, just doesnt show the react frontend
You need to add a static file server
What are you using to build your frontend?
And please, for heaven's sake, please don't say create-react-app
um
it would be that..
Oh dear
Uh, I'm afraid I don't know how you would hook that up to a custom file server, sorry
If you switched to Vite, I could tell you
ah, its all good
ill look into next.js tho
Generally, though, please read https://react.dev/learn/start-a-new-react-project
Start a New React Project – React
The library for web and native user interfaces
Cool!
If you're using Next.js, I'd suggest you check out Vercel for hosting - the edge isn't actually just marketing jargon.
I share the same sentiment as aleks about create-react-app, it's bad
but I do know how to hook it into a static file server
so send me a link to your repo and I'll see about modifying your project accordingly
Apologies for the late reply, I managed to get it situated and working now
but why would react app be bad to work with?
It's deprecated
It runs on Webpack, which the creator of Webpack recommends against using
There are much better options, like Vite, Rollup, or esbuild
and because it's default start command starts a dev server that should never be run on railway, so out of curiosity, how did you get it running
not going to lie, i have absolutely no idea
ill be glad to share the repo but yea
idk anything about react
share the repo please
you will want to gitignore the build folder
gotcha
also you are using react-scripts start
big big no no
wdym
^
oh
i will fix
thank ya
have you set any custom build or start commands in the service settings?
https://test-service2.up.railway.app/
only uses 70mb of ram now
uhh not that i know of
i didn’t rly tinker with anything honestly
have you set a PORT in the service variables?
nope
only files that where changed are package.json, package-lock.json, and the .gitignore file
you'll want to delete the build folder from your repo, and the new . gitignore file will ignore the build folder from now on
gotcha, if ya dont mind what'd ya add to package
serve
look at the start command
ah
what does serve do?
serve is far more suited to run a web site, the original start command starts a dev server, and you never wanna run a dev server in prod
ah
all good now?
aye preciate your help man!
no problem! glad I could help!