Environment variables cannot be accessed in api routes when deployed on Vercel using the latest 9.4 environment variable feature.
However, when running next locally, then they do have access to the environment variables.
Steps to reproduce the behavior, please provide code snippets or a repository:
See minimal reproduction sample: https://github.com/TheHolyWaffle/env-test
The deployment on Vercel should have the same .env behaviour as when running nextjs locally using next dev.
Are you deploying using the CLI instead of through git? Potentially you're using an older version of the CLI which does not upload .env
@timneutkens I'm using the GitHub integration of Vercel, see https://github.com/TheHolyWaffle/env-test/commit/ed4c3439113539ff9639bb9d27e52e6a5ac8a630
I've doublechecked that .env file is present on Vercel:

We'll look into it and apply a fix 馃憤
Can confirm that 9.4.3-canary.1 seems to have fixed the issue: https://env-test-three.now.sh/api/print
@TheHolyWaffle thanks for checking!
I have the same problem, should I update my version of next.js? If yes, what version?
@denispixi yes you should update to the latest stable version of Next.js (v9.4.4) to resolve this
@denispixi yes you should update to the latest stable version of Next.js (v9.4.4) to resolve this
I'll try. Thanks!
Most helpful comment
Can confirm that 9.4.3-canary.1 seems to have fixed the issue: https://env-test-three.now.sh/api/print