Skip to content

Commit

Permalink
docs(errors): update invalid page config
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 21, 2022
1 parent f55f103 commit d7a713c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
38 changes: 36 additions & 2 deletions errors/invalid-page-config.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 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

Expand All @@ -23,17 +24,50 @@ config.amp = true

This is not allowed

```js
export const config = {
amp: 1 + 1 > 2,
}
```

This is not allowed

```js
export { config } from '../config'
```

This is not allowed

```js
export const config = {
runtime: `n${'od'}ejs`,
}
```

This is allowed

```js
export const config = { amp: true }
```

This is allowed

```js
export const config = {
runtime: 'nodejs',
}
```

This is allowed

```js
export const config = {
runtime: `nodejs`,
}
```

### Useful Links

- [Enabling AMP Support](https://nextjs.org/docs/advanced-features/amp-support/introduction)
- [API Middlewares](https://nextjs.org/docs/api-routes/api-middlewares)
- [Switchable Runtime](https://nextjs.org/docs/advanced-features/react-18/switchable-runtime)
2 changes: 1 addition & 1 deletion packages/next/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function warnAboutUnsupportedValue(
Log.warn(
`You have exported a \`config\` field in ${
page ? `route "${page}"` : `"${pageFilePath}"`
} that Next.js can't recognize, so it will be ignored`
} that Next.js can't recognize, so it will be ignored. See: https://nextjs.org/docs/messages/invalid-page-config`
)
warnedUnsupportedValueMap.set(pageFilePath, true)
}

0 comments on commit d7a713c

Please sign in to comment.