-
Notifications
You must be signed in to change notification settings - Fork 43
[Docs] Clarify how to access environment variables vs bindings #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Especially since Wrangler is now injecting .env into process.env, somehow the builds get injected with some .env variables and don’t need them in wrangler.jsonc nor in the dashboard (?) |
From my experience if you add values to the Wrangler config these will be available through https://developers.cloudflare.com/changelog/2025-03-11-process-env-support/ Then with Next.js you also have the Personally I have a next-on-pages project set up with the below, I assume it works the same with OpenNext:
Where |
@Juuldamen Hi, can you better elaborate the .env.production.local generation? I'm having this same problem now, I can see that the npm run build is picking .env.local, thus screwing up everything. Thanks |
"this would return both the bindings and the environment variables" unfortunately cloudflare uses the same "environment variables" term that Node.js for something different. The "(cloudflare) environment variables" available on Node.js app developpers use
Yes, the doc is right
They are, for 2 reasons:
This is poorly documented :( I feel like all of your questions are answered in the docs or do you see anything specific to add (PR welcome) |
The bindings docs explain that you can obtain the Cloudflare env using
getCloudflareContext
from"@opennextjs/cloudflare"
. In the Cloudflare Workers world, this would return both the bindings and the environment variables.However, it seems that the documentation on environment variables indicates that environment variables will be accessible on
process.env
, and in my experience, they will specifically not be available on the Cloudflare context (even if they are set in Wrangler.jsonc, etc). Does OpenNext inject environment variables from Wrangler.jsonc and Workers environment variables into process.env? Or does it only accept environment variables configured via the dashboard? If so, this should be explicitly mentioned in either bindings or Environment variables docs.The text was updated successfully, but these errors were encountered: