mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
6f162b94e1
Introduce env to next.config.js for build-time configuration
22 lines
460 B
Markdown
22 lines
460 B
Markdown
# Using `publicRuntimeConfig` with `target` set to `serverless`
|
|
|
|
#### Why This Error Occurred
|
|
|
|
In the `serverless` target environment `next.config.js` is not loaded, so we don't support `publicRuntimeConfig`.
|
|
#### Possible Ways to Fix It
|
|
|
|
Use config option `env` to set **build time** variables like such:
|
|
|
|
```js
|
|
// next.config.js
|
|
module.exports = {
|
|
env: {
|
|
special: "value"
|
|
}
|
|
}
|
|
```
|
|
|
|
```js
|
|
// pages/index.js
|
|
console.log(process.env.special) // value
|
|
``` |