4 months ago
Environment Variables Not Being Injected
Issue
Two environment variables (RESEND_API_KEY and FRONTEND_URL) are configured in the Railway Variables tab but are NOT being injected into the production environment at runtime.
Evidence
Added debug logging to server startup:
console.log('RESEND_API_KEY exists:', !!process.env.RESEND_API_KEY);
console.log('FRONTEND_URL:', process.env.FRONTEND_URL);
Deploy log output:
RESEND_API_KEY exists: false
RESEND_API_KEY value: undefined
FRONTEND_URL: undefined
What's Working
Other variables ARE injecting correctly:
JWT_SECRET
DATABASE_URI
FROM_EMAIL
RECAPTCHA_SECRET
PORT
NODE_ENV
Expected: 9 variables | Actually injected: 7 variables
What We've Tried
Added variables via Variables UI
Verified names and values are correct
Multiple manual redeployments
Removed dotenv from production code
Tried as both service and shared variables
Why are some variables injected but not these two specific ones?
Pinned Solution
4 months ago
Hey, you have click on the deploy button to apply the changes. Please check the attached video.
Attachments
7 Replies
4 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
4 months ago
Hey, can you show how your service's variable tab looks like? Service variables are applied correctly if they aren't showing a purple background. You haven't applied them, if they still show a purple background, I have attached a screenshot to illustrate what I have just said.
In the screenshot above, the FOO service variable has not yet been applied and can be applied by deploying it via the Deploy button.
Attachments
4 months ago
tac42
i've deployed many times after adding these vars. then removed them and added them again and deployed again but its always purple and look at the second screenshot showing deployment missing them.
4 months ago
Hey, you have click on the deploy button to apply the changes. Please check the attached video.
Attachments
4 months ago
yes honestly it was as simple as your video but i swear i didn't see the button until you pointed it out. and what is the difference of deploying from the main setting VS. the variable tab. maybe a new variables should be pushed when you deploy from the regular button and or the git push. but that's just a suggestion because i don't really care at this point so long as my website works.
Thank you!
tac42
yes honestly it was as simple as your video but i swear i didn't see the button until you pointed it out. and what is the difference of deploying from the main setting VS. the variable tab. maybe a new variables should be pushed when you deploy from the regular button and or the git push. but that's just a suggestion because i don't really care at this point so long as my website works.Thank you!
4 months ago
You are welcome! The main idea is that you will need to approve the changes you have made or discard them, that is why you have explicitly approve/deploy the changes you have made. It would also be inefficient if it just deployed a single change instantly, imagine wanting to define 10 variables and all of them triggering a new deployment while your app is screaming that it is still missing the other ones you haven't defined.
Status changed to Solved uxuz • 4 months ago
