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:
parent
68db0992b6
commit
0e4fd2566f
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue