Skip to content

Block Certain Env Keys That Are Used Internally#6260

Merged
timneutkens merged 7 commits intocanaryfrom
block-node-env
Feb 15, 2019
Merged

Block Certain Env Keys That Are Used Internally#6260
timneutkens merged 7 commits intocanaryfrom
block-node-env

Conversation

@dav-is
Copy link
Contributor

@dav-is dav-is commented Feb 12, 2019

Closes: #6244

This will block the following keys:

NODE_.+
__.+

There doesn't seem to be a way to simulate a failed build or else I'd add tests for it.

@timneutkens
Copy link
Member

We don't have to block these:

  • CONFIG_BUILD_ID is only used in tests
  • PORT is not used by Next.js

What we should block:

  • NODE_ENV
  • __NEXT_DIST_DIR

Potentially vars starting in __NEXT_ to keep an internal private namespace for replacement. Then we should also update this:
https://github.com/zeit/next.js/blob/canary/packages/next/server/hot-reloader.js#L170-L171 to reflect that. IMO that sounds like a good solution.

@dav-is dav-is mentioned this pull request Feb 12, 2019
3 tasks
Copy link
Member

@Timer Timer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if tests passed (they did).


#### Why This Error Occurred

Next.js configures internal variables for replacement itself. These start with `__` or `NODE_`, for this reason they are not allowed as values for `env` in `next.config.js`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better as:

Next.js uses special environment variables to configure itself. Because of this, you are not allowed to use values that start with __ or NODE_ for env in next.config.js.

@timneutkens timneutkens merged commit 1e5d090 into canary Feb 15, 2019
@timneutkens timneutkens deleted the block-node-env branch February 15, 2019 16:49
@lock lock bot locked as resolved and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throw when NODE_ENV is added to env in next.config.js

3 participants