1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Block certain env keys that are used internally

This commit is contained in:
Connor Davis 2019-02-11 22:09:34 -06:00
parent 68db0992b6
commit 0e4fd2566f
No known key found for this signature in database
GPG key ID: 9E3CD9875570DB83

View file

@ -294,10 +294,13 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
new webpack.DefinePlugin(Object.assign(
{},
config.env ? Object.keys(config.env)
.reduce((acc, key) => ({
...acc,
...{ [`process.env.${key}`]: JSON.stringify(config.env[key]) }
}), {}) : {},
.reduce((acc, key) => {
if (/^(?:NODE_\w+)|(?:NEXT_\w+)|(?:__\w+)|(?:CONFIG_BUILD_ID)|(?:PORT)$/.test(key.toUpperCase())) throw new Error(`Next.js config env cannot have key of ${key}`)
return {
...acc,
...{ [`process.env.${key}`]: JSON.stringify(config.env[key]) }
}
}, {}) : {},
{
'process.crossOrigin': JSON.stringify(config.crossOrigin),
'process.browser': JSON.stringify(!isServer)