R

Railway

βœ‹ο½œhelp

Join Server

Service URL ENV variable is empty

Eelis5/24/2023
The variable for a static URL of one of the services is empty (despite having a domain associated with it) - other services (and env variables) who are dependent on it are failing.

Variable name: RAILWAY_SERVICE_MPC_API_URL
Eelis5/24/2023
f568f607-e4d1-4517-ba1a-537dc9a8be86
Bbrody5/24/2023
can you send a browser screenshot of your project
Eelis5/24/2023
what kind of screenshot?
Eelis5/24/2023
railway project?
Bbrody5/24/2023
bruh
Bbrody5/24/2023
full screenshot of your browser window with the railway project in question open
Eelis5/24/2023
Bbrody5/24/2023
and what service is trying to access RAILWAY_SERVICE_MPC_API_URL
Eelis5/24/2023
docs mention the static url env vars to be RAILWAY_{serviceName}_STATIC_URL

while the env variable is actually RAILWAY_SERVICE_{serviceName}_URL
Bbrody5/24/2023
i know, i dont understand that either RAILWAY_SERVICE_MPC_API_URL would be correct
Eelis5/24/2023
the mpc service is trying to get the RAILWAY_SERVICE_MPC_API_URL
Eelis5/24/2023
it is correct -it's just an empty string
Eelis5/24/2023
do note that it worked - but since yesterday it's reporting as empty string
Bbrody5/24/2023
okay now what exactly is the mpc service?
Eelis5/24/2023
mpc service is a web client service (nextjs app)
Bbrody5/24/2023
can you show me how you are accessing the variable in code
Eelis5/24/2023
note that I do have the RAILWAY_SERVICE_MPC_API_URL variable provided - it's just that it's empty string
Eelis5/24/2023
process.env.RAILWAY_SERVICE_MPC_API_URL
Eelis5/24/2023
Eelis5/24/2023
variable exists...
Bbrody5/24/2023
is that an .env file?
Eelis5/24/2023
that's from the app
Eelis5/24/2023
it's a dump of the env vars
Bbrody5/24/2023
while running on railway?
Eelis5/24/2023
the project doesn't have .env vars in the git repo
Eelis5/24/2023
while running on railway?
yes
Bbrody5/24/2023
ssr next app?
Eelis5/24/2023
yea
Eelis5/24/2023
next13
Bbrody5/24/2023
dont variables have to be prefixed with something?
Bbrody5/24/2023
like NEXT_
Eelis5/24/2023
mpc-api is just an express app
Eelis5/24/2023
it also has these variables
Eelis5/24/2023
also empty strings
Eelis5/24/2023
like NEXT_
NEXT_PUBLIC_ if you want them on public
Eelis5/24/2023
e.g. front-end
Eelis5/24/2023
any env variables that are not prefixed are available on the server
Bbrody5/24/2023
im sorry i cant reproduce this
https://utilities.up.railway.app/env-vars
Bbrody5/24/2023
you must be overriding them or something
Eelis5/24/2023
Overriding them? nope...
Eelis5/24/2023
they're just empty string vars
Eelis5/24/2023
i think it's a bud on railway's side...
Eelis5/24/2023
im sorry i cant reproduce this
Yes, because it should work - but since yesterday it just doesn't
Eelis5/24/2023
bud=bug πŸ˜„
Bbrody5/24/2023
deploy an absolute bare minimun nodejs service, no framework, nothing, just index.js and package.json and inside that index.js file simply put
console.log(process.env);
Eelis5/24/2023
how do I see the console log after deploying?
Eelis5/24/2023
Done
Eelis5/24/2023
vars are empty but that's because the PR env domains are empty - so it makes sense
Eelis5/24/2023
added domains for the services
Eelis5/24/2023
and rebuilding the test
Eelis5/24/2023
now with domains set, RAILWAY env vars are still empty:
Bbrody5/24/2023
remind me, is this the first time you mentioned this being a pr environment?
Eelis5/24/2023
it happens on non-pr envs
Eelis5/24/2023
now after rebuilding with domains set the vars aren't empty
Bbrody5/24/2023
show me the code behind these printouts please?
Eelis5/24/2023
index.js:
console.log('process.env:', process.env)
Eelis5/24/2023
scripts.start/build are both set to node index.js
Bbrody5/24/2023
can you share the repo for that?
Eelis5/24/2023
no, sorry
Eelis5/24/2023
it's a simple nodejs with package.json and index.js as requested
Eelis5/24/2023
you mean to make a public repo with that code?
Bbrody5/24/2023
id like to see the exact code that made this output
Eelis5/24/2023
Eelis5/24/2023
this helps? xD
Eelis5/24/2023
Bbrody5/24/2023
the vars arent empty?
Eelis5/24/2023
after rebuilding - no, aren't empty
Eelis5/24/2023
filled correctly
Eelis5/24/2023
but on production env's they are empty
Eelis5/24/2023
despite having domains set
Bbrody5/24/2023
okay will flag team
Eelis5/24/2023
πŸ™
Eelis5/24/2023
thank you!
Bbrody5/24/2023
sorry it took so long to get to this point, i just had to be sure it was on railway's end
Eelis5/24/2023
all good! looking forward for their reply
Eelis5/29/2023
πŸ‘‹
UUUnknown User5/30/2023
Message Not Public
Sign In & Join Server To View
Rrc5/30/2023
Hey! Sorry for the delay here. Can you try re-deploying the env-vars test service? I wanna see what happens under the hood
Eelis5/30/2023
redeploying now
Eelis5/30/2023
deployment id: a7a2cd62-8cbe-4707-a5a9-acda79551715
Rrc5/31/2023
interesting, could you try re-creating a new service for this? I'm wondering if the env vars we're picking up is stuck in a previous state prior to service creation
Eelis5/31/2023
e.g. remove the service and add it from scratch?
Rrc5/31/2023
yep
Eelis5/31/2023
running
Eelis5/31/2023
you can see that for the production env all the RAILWAY_SERVICE_MPC_*_URL are empty strings
Eelis5/31/2023
staging as well
Eelis5/31/2023
if it's of any help - it seems that the auto-generated domains are correctly populated
Eelis5/31/2023
in the env vars, that is
Bbrody5/31/2023
then what isn't being populated
Eelis6/1/2023
all the other services
Eelis6/1/2023
Eelis6/1/2023
redeployed - env vars for service urls are empty 😦
Eelis6/1/2023
you can see the services (on the left) do have URLs, but the env vars echoed in app are empty...
Rrc6/1/2023
I can confirm. Going to raise this up, thanks!
Eelis6/2/2023
Thanks!