Comments (3)
Hi,
I think this is expected behaviour on Edge:
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.
https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
#39705 has some more information too.
I worked around the problem by running a script as part of our CI process that takes environment variables from the .env
files and uses the Vercel API to add them as environment variables to the Vercel project settings, being careful not to override any variables that we don't want to be accidentally overridden.
from next.js.
Hey @philwolstenholme, thanks for the reply. You are right. Unfortunately the main use case for .env.production
is to set ENV variables based on values set by Vercel. For example VERCEL_BRANCH_URL
to setup Auth0 (setting AUTH0_BASE_URL for previews).
With the current state, it requires either manual deployment step setting AUTH0_BASE_URL
or using non-default variable names in the code.
Also, it is quite confusing (and bad DX) to have ENV variables configured in the dashboard available in runtime and from .env*
files only with a public prefix.
I understand now how it works for end users, and can imagine what is going on when code is deployed to the edge. So this isn't a bug per se, but I still believe there is space for improvement.
from next.js.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
from next.js.
Related Issues (20)
- Turbopack does not resolve serverExternalPackages HOT 1
- SSL issue and phishing issue made twitter block our website HOT 2
- HMR doesn't work on parallel routes while using turbopack HOT 4
- Revalidate ignored for index route of a catch all route HOT 1
- Inconsistent parsing of data URLs in CSS in Next 14 HOT 1
- intercepting routes not rendering under nested route HOT 3
- Can't use Knex in instrumentation hook HOT 3
- Tab title is reset for a moment when navigating to a dynamic page HOT 1
- Dev mode fail s with(WasmHash._updateWithBuffer ) HOT 1
- Parallel Routes cause redundant RSC fetches on navigation HOT 8
- When using `<Script>` with `crossorigin` specified, `crossorigin` is missing from `<link>` that preloads the script
- Layout doesn't cache and gets 1 server re-render for each broken image link
- Fill property for Next Image doesn't seem to work. HOT 6
- 404 when redirecting in server action with subdomain rewrite rule HOT 3
- Build Error when trying to compile with 'use client' files.
- NextResponse.redirect is not working in middleware HOT 1
- Layout rerenders on same segment route change HOT 4
- Docs: Replace "twitter.com" to "x.com"
- Add option to enable Turbopack with `create-next-app` HOT 8
- Redirect URL not updating correctly in browser after successful redirect HOT 11
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.