8 months ago
Hi everyone,
I’m currently deploying a backend service on Railway, and I’m running into an issue where my Shared Variables are not being injected into the process.env
of my service.
Here’s what I’ve done so far:
I added the necessary variables (e.g.,
GOOGLE_CLIENT_ID
,GOOGLE_CLIENT_SECRET
,MONGODB_URI
, etc.) under Project Settings > Shared Variables.I confirmed that the variable names are correct and match what I’m accessing in my code (e.g.,
process.env.GOOGLE_CLIENT_ID
).I redeployed the service using
railway up
after adding the variables.However, when I log
process.env
in myserver.js
, none of these variables show up. Instead,GOOGLE_CLIENT_ID
and others appear asundefined
.
Am I missing something in how shared variables are supposed to work? I have this working locally, and it's kinda confusing because I have some variables not being injected such as GOOGLE_CLIENT_ID
, GOOGLE_CLIENT_SECRET
, MONGODB_URI, and FRONTEND_URL
, while I have others such as NODE_ENV and PORT
being injected. Any guidance or suggestions would be greatly appreciated!
Thanks in advance!
1 Replies
8 months ago
You need to reference the shared varaible within the service settings or else it won't get exposed to the deployment.
It seems that you are now using manual references but in the future- you can use the variable template syntax to reference the Railway defined values like so ${{GOOGLE_CLIENT_ID}}
Hopefully that clears things up. (And sorry...)
Status changed to Awaiting User Response Railway • 8 months ago
a month ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • about 2 months ago