Supabase Auth not working after deploying to Railway

meliksahkole
FREEOP

19 days 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_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY in Railway’s Variables section (same as my local .env.local)

  • Checked that supabaseClient.ts uses process.env.NEXT_PUBLIC_SUPABASE_URL and process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY

  • Verified 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!

$10 Bounty

7 Replies

Railway
BOT

19 days 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!


19 days 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.

meliksahkole
FREEOP

19 days 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.

meliksahkole
FREEOP

19 days 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

19 days 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.

meliksahkole
FREEOP

19 days 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.


coding-dynasty
PRO

16 days ago

check if you are deploying the right git branch on railway settings tab four service?


Loading...