rsnext/errors/invalid-page-config.md
Jan Klimo c11310b0f1
Fix a typo in docs (#40501)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we
request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-09-13 13:22:25 +02:00

1.6 KiB

Invalid Page / API Route Config

Why This Error Occurred

In one of your pages or API Routes you did export const config with an invalid value.

Possible Ways to Fix It

The page's config must be an object initialized directly when being exported and not modified dynamically. The config object must only contain static constant literals without expressions.

Not Allowed Allowed
// `config` should be an object
export const config = 'hello world'
export const config = {}
export const config = {}
// `config.amp` is defined after `config` is exported
config.amp = true

// `config.amp` contains a dynamic expression
export const config = {
  amp: 1 + 1 > 2,
}
export const config = {
  amp: true,
}

export const config = {
  amp: false,
}
// `config.runtime` contains a dynamic expression
export const config = {
  runtime: `node${'js'}`,
}
export const config = {
  runtime: 'nodejs',
}
export const config = {
  runtime: `nodejs`,
}
// Re-exported `config` is not allowed
export { config } from '../config'
export const config = {}