Files
next.js/errors/invalid-page-config.mdx
T
2d549683a6 docs: change runtime value in example code (#72274)
## Description
[Invalid Page / API Route
Config](https://nextjs.org/docs/messages/invalid-page-config) shows some
examples.
However, runtime examples are same `nodejs` runtime.
Then I add `edge` value instead of duplicate value.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

Co-authored-by: Delba de Oliveira <[email protected]>
2024-11-06 08:16:38 +00:00

122 lines
1.6 KiB
Plaintext

---
title: Invalid Page / API Route Config
---
## Why This Error Occurred
In one of your pages or API Routes, you used `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.
<table>
<thead>
<tr>
<th>Not Allowed</th>
<th>Allowed</th>
</tr>
</thead>
<tbody>
<tr>
<td>
```js
// `config` should be an object
export const config = 'hello world'
```
</td>
<td>
```js
export const config = {}
```
</td>
</tr>
<tr>
<td>
```js
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,
}
```
</td>
<td>
```js
export const config = {
amp: true,
}
export const config = {
amp: false,
}
```
</td>
</tr>
<tr>
<td>
```js
// `config.runtime` contains a dynamic expression
export const config = {
runtime: `node${'js'}`,
}
```
</td>
<td>
```js
export const config = {
runtime: 'nodejs',
}
export const config = {
runtime: `edge`,
}
```
</td>
</tr>
<tr>
<td>
```js
// Re-exported `config` is not allowed
export { config } from '../config'
```
</td>
<td>
```js
export const config = {}
```
</td>
</tr>
</tbody>
</table>
## Useful Links
- [Enabling AMP Support](/docs/pages/building-your-application/configuring/amp)
- [API Routes Request Helpers](/docs/pages/building-your-application/routing/api-routes)
- [Edge and Node.js Runtimes](/docs/pages/building-your-application/rendering/edge-and-nodejs-runtimes)