Code Monkey home page Code Monkey logo

Comments (2)

priyxansh avatar priyxansh commented on July 22, 2024 3

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.

ijxy avatar ijxy commented on July 22, 2024

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)

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.