cli icon indicating copy to clipboard operation
cli copied to clipboard

allow changing environment variables for edge functions on the command-line

Open overlordofmu opened this issue 2 years ago • 0 comments

Describe the bug

There is a requirement to be able to override the "Local development (Netlify CLI)" context for an environment variable set in the web UI at Netlify when using the CLI by setting the environment variable in the CLI's environment including the environment variables passed to the CLI process command via the shell like so:

EXAMPLE="value" netlify dev

Such an environment variable is passed to functions and the build command but not to the local edge function environment.

Being able to add or override the environment variable set in the UI is a requirement for some local testing use-cases.

Steps to reproduce

  1. Set an environment variable EXAMPLE in the web UI and give it different values for each context:

image

  1. Link the local repo directory with the site using netlify link.
  2. Make an edge function for the site that console.logs() the environment variable EXAMPLE (with something like console.log("EXAMPLE is: ", Netlify.env.get("EXAMPLE")).
  3. Start the development environment locally and override the environment variable using: EXAMPLE="test" netlify dev.
  4. Note that the environment variable EXAMPLE still is set to development and not test in the local edge functions.

Configuration

N/A

Environment

System: OS: macOS 13.5 CPU: (10) arm64 Apple M1 Pro Memory: 2.75 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm npmGlobalPackages: netlify-cli: 15.9.1

overlordofmu avatar Jul 27 '23 03:07 overlordofmu