Loading different env variables with Nextjs and next-on-pages
Aim
I want to call Cloudflare env variables such as:
Problem
When I run
npx @cloudflare/next-on-pages@1
, the Vercel build fails with the following error:
So, that makes me think that my configuration is broken.
I am happy to create .env
files, but I want to avoid duplicate data entry (e.g., settings the both env variable in .env.dev
and wrangler.toml
).1 Reply
I think I solved it, but it would be nice to get confirmation from other devs.
I created 2
.env
files:
- .env.development.local
- .env.production.local
They are loaded as needed specified in the package.json
scripts.
I manually added .env.production.local
variables to wrangler.toml
. This is the bit I am conscious about since there is data duplication. Any recommendations on solving this?