R
Railway14mo ago
elis

Service URL ENV variable is empty

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
67 Replies
Percy
Percy14mo ago
Project ID: f568f607-e4d1-4517-ba1a-537dc9a8be86
elis
elis14mo ago
f568f607-e4d1-4517-ba1a-537dc9a8be86
Brody
Brody14mo ago
can you send a browser screenshot of your project
elis
elis14mo ago
what kind of screenshot? railway project?
Brody
Brody14mo ago
bruh full screenshot of your browser window with the railway project in question open
elis
elis14mo ago
Brody
Brody14mo ago
and what service is trying to access RAILWAY_SERVICE_MPC_API_URL
elis
elis14mo ago
docs mention the static url env vars to be RAILWAY_{serviceName}_STATIC_URL while the env variable is actually RAILWAY_SERVICE_{serviceName}_URL
Brody
Brody14mo ago
i know, i dont understand that either RAILWAY_SERVICE_MPC_API_URL would be correct
elis
elis14mo ago
the mpc service is trying to get the RAILWAY_SERVICE_MPC_API_URL it is correct -it's just an empty string do note that it worked - but since yesterday it's reporting as empty string
Brody
Brody14mo ago
okay now what exactly is the mpc service?
elis
elis14mo ago
mpc service is a web client service (nextjs app)
Brody
Brody14mo ago
can you show me how you are accessing the variable in code
elis
elis14mo ago
note that I do have the RAILWAY_SERVICE_MPC_API_URL variable provided - it's just that it's empty string process.env.RAILWAY_SERVICE_MPC_API_URL
elis
elis14mo ago
elis
elis14mo ago
variable exists...
Brody
Brody14mo ago
is that an .env file?
elis
elis14mo ago
that's from the app it's a dump of the env vars
Brody
Brody14mo ago
while running on railway?
elis
elis14mo ago
the project doesn't have .env vars in the git repo
while running on railway?
yes
Brody
Brody14mo ago
ssr next app?
elis
elis14mo ago
yea next13
Brody
Brody14mo ago
dont variables have to be prefixed with something? like NEXT_
elis
elis14mo ago
mpc-api is just an express app it also has these variables also empty strings
like NEXT_
NEXT_PUBLIC_ if you want them on public e.g. front-end any env variables that are not prefixed are available on the server
Brody
Brody14mo ago
im sorry i cant reproduce this https://utilities.up.railway.app/env-vars you must be overriding them or something
elis
elis14mo ago
Overriding them? nope... they're just empty string vars i think it's a bud on railway's side...
im sorry i cant reproduce this
Yes, because it should work - but since yesterday it just doesn't bud=bug 😄
Brody
Brody14mo ago
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);
console.log(process.env);
elis
elis14mo ago
how do I see the console log after deploying?
elis
elis14mo ago
Done vars are empty but that's because the PR env domains are empty - so it makes sense added domains for the services and rebuilding the test
elis
elis14mo ago
now with domains set, RAILWAY env vars are still empty:
Brody
Brody14mo ago
remind me, is this the first time you mentioned this being a pr environment?
elis
elis14mo ago
it happens on non-pr envs now after rebuilding with domains set the vars aren't empty
Brody
Brody14mo ago
show me the code behind these printouts please?
elis
elis14mo ago
index.js:
console.log('process.env:', process.env)
console.log('process.env:', process.env)
scripts.start/build are both set to node index.js
Brody
Brody14mo ago
can you share the repo for that?
elis
elis14mo ago
no, sorry it's a simple nodejs with package.json and index.js as requested you mean to make a public repo with that code?
Brody
Brody14mo ago
id like to see the exact code that made this output
elis
elis14mo ago
elis
elis14mo ago
this helps? xD
elis
elis14mo ago
Brody
Brody14mo ago
the vars arent empty?
elis
elis14mo ago
after rebuilding - no, aren't empty filled correctly but on production env's they are empty despite having domains set
Brody
Brody14mo ago
okay will flag team
elis
elis14mo ago
🙏 thank you!
Brody
Brody14mo ago
sorry it took so long to get to this point, i just had to be sure it was on railway's end
elis
elis14mo ago
all good! looking forward for their reply
Percy
Percy14mo ago
Flagging this thread. A team member will be with you shortly.
elis
elis14mo ago
👋
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
Ray
Ray14mo ago
Hey! Sorry for the delay here. Can you try re-deploying the env-vars test service? I wanna see what happens under the hood
elis
elis14mo ago
redeploying now deployment id: a7a2cd62-8cbe-4707-a5a9-acda79551715
Ray
Ray14mo ago
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
elis
elis14mo ago
e.g. remove the service and add it from scratch?
Ray
Ray14mo ago
yep
elis
elis14mo ago
running you can see that for the production env all the RAILWAY_SERVICE_MPC_*_URL are empty strings staging as well if it's of any help - it seems that the auto-generated domains are correctly populated in the env vars, that is
Brody
Brody14mo ago
then what isn't being populated
elis
elis14mo ago
all the other services
elis
elis14mo ago
elis
elis14mo ago
redeployed - env vars for service urls are empty 😦 you can see the services (on the left) do have URLs, but the env vars echoed in app are empty...
Ray
Ray14mo ago
I can confirm. Going to raise this up, thanks!
elis
elis14mo ago
Thanks!
onurgu
onurgu14mo ago
I am having this problem too
Brody
Brody14mo ago
it will be looked into https://discord.com/channels/713503345364697088/1114802678015479868/1114802678015479868
RAILWAY_SERVICE_${SERVICENAME}_URL environment variable may not work for some users.
Elwin | OKX
Elwin | OKX13mo ago
I am encountering the same issue here, please help to fix this.
Brody
Brody13mo ago
it will be looked into https://discord.com/channels/713503345364697088/1114802678015479868/1114802678015479868
RAILWAY_SERVICE_${SERVICENAME}_URL environment variable may not work for some users.
Ray
Ray13mo ago
I haven't been able to reproduce this issue. Can y'all share a link to your service please?