2022-07-21 21:56:52 +02:00
|
|
|
# Invalid Page / API Route Config
|
2019-07-15 22:54:35 +02:00
|
|
|
|
|
|
|
#### Why This Error Occurred
|
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
In one of your pages or API Routes you did `export const config` with an invalid value.
|
2019-07-15 22:54:35 +02:00
|
|
|
|
|
|
|
#### Possible Ways to Fix It
|
|
|
|
|
2020-08-17 19:24:18 +02:00
|
|
|
The page's config must be an object initialized directly when being exported and not modified dynamically.
|
2022-09-13 13:22:25 +02:00
|
|
|
The config object must only contain static constant literals without expressions.
|
2019-07-15 22:54:35 +02:00
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Not Allowed</th>
|
|
|
|
<th>Allowed</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>
|
2019-07-15 22:54:35 +02:00
|
|
|
|
|
|
|
```js
|
2022-07-21 21:56:52 +02:00
|
|
|
// `config` should be an object
|
2019-07-15 22:54:35 +02:00
|
|
|
export const config = 'hello world'
|
|
|
|
```
|
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
|
|
|
|
```js
|
|
|
|
export const config = {}
|
|
|
|
```
|
|
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>
|
2020-08-17 19:24:18 +02:00
|
|
|
|
|
|
|
```js
|
2022-07-21 21:56:52 +02:00
|
|
|
export const config = {}
|
|
|
|
// `config.amp` is defined after `config` is exported
|
2020-08-17 19:24:18 +02:00
|
|
|
config.amp = true
|
2022-07-21 21:56:52 +02:00
|
|
|
|
|
|
|
// `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,
|
|
|
|
}
|
2020-08-17 19:24:18 +02:00
|
|
|
```
|
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
</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: `nodejs`,
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>
|
2020-08-17 19:24:18 +02:00
|
|
|
|
|
|
|
```js
|
2022-07-21 21:56:52 +02:00
|
|
|
// Re-exported `config` is not allowed
|
2020-08-17 19:24:18 +02:00
|
|
|
export { config } from '../config'
|
|
|
|
```
|
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2019-07-15 22:54:35 +02:00
|
|
|
|
|
|
|
```js
|
2022-07-21 21:56:52 +02:00
|
|
|
export const config = {}
|
2019-07-15 22:54:35 +02:00
|
|
|
```
|
|
|
|
|
2022-07-21 21:56:52 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2019-07-15 22:54:35 +02:00
|
|
|
### Useful Links
|
|
|
|
|
2020-06-18 11:54:07 +02:00
|
|
|
- [Enabling AMP Support](https://nextjs.org/docs/advanced-features/amp-support/introduction)
|
2022-08-09 04:02:14 +02:00
|
|
|
- [API Routes Request Helpers](https://nextjs.org/docs/api-routes/request-helpers)
|
2022-07-21 21:56:52 +02:00
|
|
|
- [Switchable Runtime](https://nextjs.org/docs/advanced-features/react-18/switchable-runtime)
|