a month ago
Hey everyone
I’m having trouble getting Supabase Authentication (email + Google login) to work after deploying my Next.js app to Railway.
Everything works perfectly on localhost:3000, but in production (on my Railway domain) the login/signup process fails.
In the browser console, I get errors like:
[Supabase] Environment variables missing in production environment (Google OAuth)
URL: ❌, KEY: ❌
Here’s what I’ve already done:
Added
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYin Railway’s Variables section (same as my local.env.local)Checked that
supabaseClient.tsusesprocess.env.NEXT_PUBLIC_SUPABASE_URLandprocess.env.NEXT_PUBLIC_SUPABASE_ANON_KEYVerified that my Supabase “Site URL” and “Redirect URLs” are correctly set (including my Railway domain)
Redeployed (and even rebuilt) the app multiple times
Despite all this, Supabase still can’t find the environment variables in production — it keeps saying they’re missing.
It seems like Next.js can’t access the NEXT_PUBLIC_ environment variables at build time on Railway, even though they’re clearly defined in the dashboard.
Has anyone faced this before?
How can I make sure these public environment variables are properly available to the Next.js frontend in Railway’s production environment?
Thanks in advance
Any help or pointers would be hugely appreciated!
7 Replies
a month ago
Hey there! We've found the following might help you get unblocked faster:
🧵 FastAPI App Crashing on Startup - Environment Variables Not Injected
🧵 I'm unable to connect to my Postgres database hosted on Supabase.
If you find the answer from one of these, please let us know by solving the thread!
a month ago
Hey, are you sure that you have deployed the service variables? You will have to explicitly deploy them once you have defined them in the UI.
Attachments
uxuz
Hey, are you sure that you have deployed the service variables? You will have to explicitly deploy them once you have defined them in the UI.
a month ago
Yes, I am sure everything already deployed
Attachments
uxuz
Hey, are you sure that you have deployed the service variables? You will have to explicitly deploy them once you have defined them in the UI.
a month ago
https://resuwon-production.up.railway.app/ you may also check this problem, ı can't fix it from yesterday
meliksahkole
https://resuwon-production.up.railway.app/ you may also check this problem, ı can't fix it from yesterday
a month ago
Visiting your site and attempting to create an account shows an error message that apparently says that the Supabase configuration is missing and is asking for a .env.local file, is this a hard coded message? If not, then you would want to check if you are overwriting this behavior somewhere in your configs.
uxuz
Visiting your site and attempting to create an account shows an error message that apparently says that the Supabase configuration is missing and is asking for a .env.local file, is this a hard coded message? If not, then you would want to check if you are overwriting this behavior somewhere in your configs.
a month ago
It is a hard coded message, you may check on console real problem. But gpt says me "your problem is coming from variables at railway." I can use in localhost with no problem. I can create account.
a month ago
check if you are deploying the right git branch on railway settings tab four service?