Giter Site home page Giter Site logo

Comments (3)

philwolstenholme avatar philwolstenholme commented on June 9, 2024

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.

freaz avatar freaz commented on June 9, 2024

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.

github-actions avatar github-actions commented on June 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.