rsnext/errors/serverless-publicRuntimeConfig.md
JJ Kasper 5b574fc778
Update to error on usage of serverRuntimeConfig with serverless (#9030)
* Update to error on usage of serverRuntimeConfig with serverless

* Add tests for errors for serverless and runtime configs

* Update docs wording
2019-10-10 16:56:38 -05:00

514 B

Using publicRuntimeConfig or serverRuntimeConfig 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 or serverRuntimeConfig.

Possible Ways to Fix It

Use config option env to set build time variables like such:

// next.config.js
module.exports = {
  env: {
    special: 'value',
  },
}
// pages/index.js
console.log(process.env.special) // value