Skip to content

Commit

Permalink
Fix NEXT_PUBLIC env values not being inlined (#11896)
Browse files Browse the repository at this point in the history
* Clean up env tests a bit

* Fix NEXT_PUBLIC env values not being inlined

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
  • Loading branch information
ijjk and Timer authored Apr 15, 2020
1 parent 6202a7f commit 2b488ab
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 397 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ export default async function getBaseWebpackConfig(
? Object.keys(process.env).reduce(
(prev: { [key: string]: string }, key: string) => {
if (key.startsWith('NEXT_PUBLIC_')) {
prev[key] = process.env[key]!
prev[`process.env.${key}`] = JSON.stringify(process.env[key]!)
}
return prev
},
Expand Down
15 changes: 15 additions & 0 deletions test/integration/env-config/app/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
experimental: {
pageEnv: true,

async redirects() {
return [
{
source: '/hello',
permanent: false,
destination: `/${process.env.NEXT_PUBLIC_TEST_DEST}`,
},
]
},
},
}
16 changes: 0 additions & 16 deletions test/integration/env-config/app/pages/next-config-loaded-env.js

This file was deleted.

Loading

0 comments on commit 2b488ab

Please # to comment.