React Express app in production thinks that it is in development?
Hi there,
I am using process.env.NODE_ENV to determine the relative environment of my app between dev and prod. Yet for some reason, my app in production keeps tells me on a console.log() that it is in development thereby using the development url(localhost) while in production.
I have added "production" as an environment variable in the railway env variables as well as added "node_env=production" to my build script. Though I believe that "npm run build" already sets "production" on default.
It's fairly basic app currently and I thought I'd post here before I attempt StackOverflow π If you have any leads I would greatly appreciate it π
15 Replies
Project ID:
04753170-71db-45df-aab9-a9c3082c9230
You might find these helpful:
- Strapi - How to separate Environment?
- internal Sever Error with Deployment but Not localhost
β οΈ experimental feature
04753170-71db-45df-aab9-a9c3082c9230
send the repo over and I'll have a look at it later tonight
GitHub
GitHub - IliaZolas/ramen
Contribute to IliaZolas/ramen development by creating an account on GitHub.
Thatβs the frontend
Backend
okay I'm quite busy today, so maybe someone else could help, or I will look at it later tonight
But I think the frontend is all you need to look at
Take your time
It is not urgent
React App
Web site created using create-react-app
files changed/added:
package.json and package-lock.json changed (added serve)
added a .gitignore file to ignore the build folder since you shouldn't be committing the build folder to github.
you do have build warning so you can set
CI
= false in your service variables (not the build command please), or just fix the warnings because they where nothing complicated
for more information you can read my readme for a create-react-app railway template i put together
https://github.com/brody192/create-react-app-starter/blob/main/README.mdThanks Brody! Will take a look
excellent, thanks again Brody, fastest support ever
just a little reminder, you'll want to add the .gitignore file I provided in my zip file to your project and then delete the build folder in your repo, then the .gitignore file I provided will prevent the build folder from being pushed to your repo. we want railway to build your site and having a build folder already in your repo can cause issues down the line
Ooooooooooooooh ok thank you π
no problem!