netlify / netlify/cli

fix(command-dev): align functions default env variables with production

Open
#2,358 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: command: dev area: functions type: bug
Dominant language
TypeScript
Stars
1.9k
Forks
474
Avg merge
23h 30m
Merged PRs (30d)
53

Description

Describe the bug

Related to https://github.com/netlify/cli/pull/2348

It seems Netlify Dev passes URL and DEPLOY_URL to functions, but in production we only pass URL.
We'll need to figure out what built-in ones are passed to functions and add those to the CLI.

To Reproduce

  1. Clone the https://github.com/erezrokah/netlify-build-reproductions repo
  2. Switch to the pr_2348 branch
  3. ntl init
  4. ntl deploy
  5. Invoke the live function https://cli-pr-2348--<site>.netlify.app/.netlify/functions/index
  6. ntl dev
  7. Invoke the local function http://localhost:8888/.netlify/functions/index

See that the live function only returns the URL env variable and the local one returns DEPLOY_URL.

  System:
    OS: macOS 11.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.00 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 7.11.1 - ~/.nvm/versions/node/v15.14.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmGlobalPackages:
    netlify-cli: 3.29.2

Expected behavior

Prod an dev environment should match

Additional context

https://docs.netlify.com/configure-builds/environment-variables/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction steps comparing the deployed function invoked through the Netlify URL with the local function invoked by ntl dev, then review the environment-variable documentation linked in the issue. Done means the built-in environment variables exposed to functions in development match those exposed in production, including the expected handling of URL and DEPLOY_URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.