diff --git a/errors/invalid-page-config.md b/errors/invalid-page-config.md index 6984a9bb1b9e..6d24391d2ea4 100644 --- a/errors/invalid-page-config.md +++ b/errors/invalid-page-config.md @@ -1,39 +1,119 @@ -# Invalid Page Config +# Invalid Page / API Route Config #### Why This Error Occurred -In one of your pages you did `export const config` with an invalid value. +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 contains static constant literals without expressions. -This is not allowed +
Not Allowed | +Allowed | +
---|---|
```js +// `config` should be an object export const config = 'hello world' ``` -This is not allowed + | ++ +```js +export const config = {} +``` + + | +
```js -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, +} +``` + + | ++ +```js +export const config = { + amp: true, +} + +export const config = { + amp: false, +} ``` -This is not allowed + | +
+ +```js +// `config.runtime` contains a dynamic expression +export const config = { + runtime: `node${'js'}`, +} +``` + + | ++ +```js +export const config = { + runtime: 'nodejs', +} +export const config = { + runtime: `nodejs`, +} +``` + + | +
```js +// Re-exported `config` is not allowed export { config } from '../config' ``` -This is allowed + | +```js -export const config = { amp: true } +export const config = {} ``` + | +
hello world
+} + +export const config = { + runtime: `something-${'real' + 1 + 'y odd'}`, +}