Nextjs not picking up env values

I have a NextJS instance that expects the SUPABASE_URL to be set in the environment prior to running. It is being set via Project settings. I can SSH into the container and verify this. I am also setting the variable inside .env.local file, but it isn’t being picked up anywhere.

After explicitly providing the missing variable names as environment variables worked. I am relieved but also absolutely baffled.

When I SSH into the container and manually start next dev then open another terminal to SSH and start the Cypress tests. It fails with the same errors complaining that variables in .env.local aren’t being set.

It seems like source .env.local doesn’t work either.

But this is how I fixed my issue:

env $(cat .env | xargs) npm run start:ci

Ref: stackoverflow com/a/20909045

Is it possible that it needs to be NEXT_PUBLIC_SUPABASE_URL vs SUPABASE_URL?

If you have it set in your project settings and can echo it out when you run a job via ssh, then you shouldn’t need to source the config.

I tried both ways. It still failed.