Commit 8c874556 authored by Ollie Monk's avatar Ollie Monk Committed by Tim Neutkens

update docs for env variables (#6889)

I got stuck for a while on not being able to set up a global method due to process.envs not being able to be destructured. Hope to allow others not to spend as much time on it as I did!

https://github.com/zeit/next.js/issues/6888
parent 6ac079f1
...@@ -1701,6 +1701,17 @@ function Index() { ...@@ -1701,6 +1701,17 @@ function Index() {
export default Index export default Index
``` ```
> **Warning:** Note that it is not possible to destructure process.env variables due to the webpack `DefinePlugin` replacing process.env.XXXX inline at build time
```js
// Will not work
const { CUSTOM_KEY, CUSTOM_SECRET } = process.env;
AuthMethod({ key: CUSTOM_KEY, secret: CUSTOM_SECRET });
// Will work as replaced inline
AuthMethod({ key: process.env.CUSTOM_KEY, secret: process.env.CUSTOM_SECRET });
```
#### Runtime configuration #### Runtime configuration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment