ENV variable doesn't get overwritten properly
./frontend/.env
./frontend/src/App.tsx
This works locally as it requests
localhost
. My desired behavior that it should request backend.customdomain.com
when deployed to Railway, but it still requests localhost
. I have attached two pictures that I set my variable to the correct value on Railway and I set my root directory to ./frontend.
I have tried reading the docs, but I can't figure out what am I doing wrong. Can you please help me?Solution:Jump to solution
Pushing your
.env
to production is almost certainly the issue, as it may be overwriting existing environment variable that you've set in Railway with options from your .env
.7 Replies
Project ID:
43338470-7ca1-41cf-a9f1-e58be877d64c
My guess is that it wants the .env to be in the very root of the project and not in the root of the frontend directory (I have a monorepo set up)
Why are you pushing your
.env
to production?You might find this guide helpful if you're deploying a monorepo
Solution
Pushing your
.env
to production is almost certainly the issue, as it may be overwriting existing environment variable that you've set in Railway with options from your .env
. adding your
.env
to your .gitignore
file and update, all your .env
values should be added in your Railway Service Variables