Comments (2)
Generally, when you load environment variables from .env* files, all the Non-NEXT-PUBLIC variables are only available in the Node.js runtime and not in the Edge runtime. This remains true when deployed on vercel too.
However when you configure variables through Vercel's project settings, all environment variables are made available to the edge runtime regardless of their prefix. This explains the inconsistency that you have been experiencing.
Good to know: When deploying your Next.js application to Vercel
, your environment variables in .env* files will not be made available to Edge Runtime, unless their name are prefixed with NEXT_PUBLIC_. We strongly recommend managing your environment variables in Project Settings
instead, from where all environment variables are available.
You can refer to these links to the NextJS documentation:
from next.js.
Ok, but why?
It doesn't make sense as it is now. You can't make the case that it is about security, because then it would also apply to non-NEXT_PUBLIC variables defined inside Vercel as well.
It is an inconsistency that makes it impossible to set new environment variables that depend on the VERCEL_ system environment variables, such as MY_ENV="https://${VERCEL_URL}"
It isn't always possible to do this in code--some libs only read environment variables (which is also a poor choice, but not the point here).
from next.js.
Related Issues (20)
- Failed To Load SWC binary for win32/x64 HOT 1
- Click the browser forward and back, and getServerSideProps does not re-execute HOT 20
- next.config.ts does not support top-level-await
- Failed to load SWC binary for win32/x64
- Custom cache handler with dynamic route + static params always shows 404 page HOT 2
- create-next-app (canary): Import of *.module.scss in Client Component causes `__webpack_require__.n is not a function` crash HOT 3
- Catch-all route also catches static assets
- basePath not creating structure correctly when output set to export HOT 3
- Localized Sitemap Doesn't Work HOT 1
- Localized Sitemap Does Not Work HOT 2
- Cookies set in middleware missing on server actions HOT 4
- basePath not creating structure correctly when output set to export
- [typedRoutes] mdx pages in app router are omitted from the Route type during `next build`
- Failed to load SWC Binary for android-arm64 HOT 1
- r is not a function when wrapping API route with a function HOT 4
- Docs: Incorrect version history for sitemap adding changeFrequency and priority attributes to sitemaps HOT 1
- next.config logging option does not log in runtime edge
- <Link> component make the page refresh new request ?? HOT 3
- Module css is not working with Parallel Route HOT 1
- Pending Promises sent from server to client component crash if they reject without a reason HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.