-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and use App Router: vercel/front#23459
- Loading branch information
1 parent
394533f
commit 44d1a1c
Showing
227 changed files
with
2,096 additions
and
2,595 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ on: | |
pull_request: | ||
paths: | ||
- 'docs/**.mdx' | ||
- 'errors/*.mdx' | ||
|
||
jobs: | ||
link-check: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
errors/404-get-initial-props.md → errors/404-get-initial-props.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# 404.js Cannot Have getInitialProps | ||
--- | ||
title: 404.js Cannot Have getInitialProps | ||
--- | ||
|
||
#### Why This Error Occurred | ||
## Why This Error Occurred | ||
|
||
In your `404.js` page you added `getInitialProps` or `getServerSideProps` which is not allowed as this prevents the page from being static and `404.js` is meant to provide more flexibility for a static 404 page. Having a static 404 page is the most ideal as this page can be served very often and if not static puts extra strain on your server and more invocations for serverless functions which increase the cost of hosting your site unnecessarily. | ||
|
||
#### Possible Ways to Fix It | ||
## Possible Ways to Fix It | ||
|
||
Remove `getInitialProps` from `404.js` and make sure no HOC's used in `404.js` attach `getInitialProps`. | ||
|
||
If you want to fetch data for your `404.js` page move it to a client side fetch inside of `componentDidMount` or `useEffect(() => {}, [])`. | ||
|
||
### Useful Links | ||
## Useful Links | ||
|
||
- [Automatic Static Optimization](https://nextjs.org/docs/advanced-features/automatic-static-optimization) | ||
- [Automatic Static Optimization](/docs/pages/building-your-application/rendering/automatic-static-optimization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# AMP Bind JSX Error | ||
--- | ||
title: AMP Bind JSX Error | ||
--- | ||
|
||
#### Why This Error Occurred | ||
## Why This Error Occurred | ||
|
||
Somewhere you used `[prop]='something'` syntax which is not allowed in JSX. | ||
|
||
#### Possible Ways to Fix It | ||
## Possible Ways to Fix It | ||
|
||
Instead you can use `data-amp-bind-prop='something'` which is a valid AMP alternative | ||
|
||
### Useful Links | ||
## Useful Links | ||
|
||
- [AMP HTML Specification](https://www.ampproject.org/docs/fundamentals/spec) | ||
- [Possible future syntax](https://github.com/ampproject/amphtml/issues/21600) |
10 changes: 6 additions & 4 deletions
10
errors/amp-export-validation.md → errors/amp-export-validation.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# AMP Export Validation | ||
--- | ||
title: AMP Export Validation | ||
--- | ||
|
||
#### Why This Error Occurred | ||
## Why This Error Occurred | ||
|
||
During export we validate AMP pages using [amphtml-validator](https://www.npmjs.com/package/amphtml-validator). Errors received from the validator will fail the export. | ||
|
||
Validation errors will cause pages to not be [indexed by AMP Caches](https://www.ampproject.org/docs/fundamentals/how_cached). | ||
|
||
#### Possible Ways to Fix It | ||
## Possible Ways to Fix It | ||
|
||
Look at the error messages and follow their appropriate links to learn more about the error and how to correct the problem. | ||
|
||
### Useful Links | ||
## Useful Links | ||
|
||
- [AMP HTML Specification](https://www.ampproject.org/docs/fundamentals/spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
errors/api-routes-static-export.md → errors/api-routes-static-export.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# API routes in Static export | ||
--- | ||
title: API routes in Static export | ||
--- | ||
|
||
#### Why This Warning Occurred | ||
|
||
An `exportPathMap` path was matched to an API route. Statically exporting a Next.js application via `next export` disables API routes. | ||
|
||
This command is meant for a static-only setup, and is not necessary to make your application static. Pages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps` | ||
|
||
#### Possible Ways to Fix It | ||
## Possible Ways to Fix It | ||
|
||
Use `next build` with platforms that don't require `next export` like https://vercel.com or remove any paths using API routes from your `exportPathMap` in `next.config.js`. | ||
|
||
### Useful Links | ||
## Useful Links | ||
|
||
- [Static HTML export](https://nextjs.org/docs/advanced-features/static-html-export) | ||
- [Static HTML export](/docs/pages/building-your-application/deploying/static-exports) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: 'App Router Static to Dynamic Error' | ||
--- | ||
|
||
## Why This Error Occurred | ||
|
||
Inside one of your `app/` pages, the page was initially generated statically at build time, and then during runtime either a fallback path or path being revalidated attempted to leverage dynamic server values e.g. `cookies()` or `headers()`. | ||
|
||
This is a hard error by default as a path generated statically can't switch between types during runtime currently. | ||
|
||
## Possible Ways to Fix It | ||
|
||
Prevent usage of these dynamic server values conditionally which can cause the static/dynamic mode of the page to differ between build time and runtime. | ||
|
||
Leverage `export const dynamic = 'force-static'` to ensure the page is handled statically regardless of the usage of dynamic server values. Alternatively, if you prefer your page to always be dynamic you can set `export const dynamic = 'force-dynamic'` and it won't attempt to have the page be statically generated. | ||
|
||
## Useful Links | ||
|
||
- [static/dynamic rendering](/docs/app/building-your-application/rendering/static-and-dynamic-rendering) | ||
- [dynamic server value methods](/docs/app/building-your-application/rendering/static-and-dynamic-rendering#dynamic-functions) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: 'Babel and `next/font` conflict' | ||
--- | ||
|
||
## Why This Error Occurred | ||
|
||
You have tried to use `next/font` with a custom babel config. When your application has a custom babel config you opt-out of the Next.js Compiler which is required to use `next/font`. | ||
|
||
## Possible Ways to Fix It | ||
|
||
- Remove your custom babel config and use the Next.js Compiler | ||
|
||
## Useful Links | ||
|
||
- [Next.js Compiler](/docs/architecture/nextjs-compiler) | ||
- [Customizing Babel Config](/docs/pages/building-your-application/configuring/babel) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Beta Middleware Used | ||
--- | ||
|
||
## Why This Error Occurred | ||
|
||
[Middleware](/docs/pages/building-your-application/routing/middleware) was beta in versions prior to `v12.2` and not yet covered by [semver](https://semver.org/). | ||
|
||
## Possible Ways to Fix It | ||
|
||
You can continue to use Middleware in versions prior to `v12.2`. However, you will need to make changes to upgrade to newer versions. | ||
|
||
If you're using Next.js on Vercel, your existing deploys using Middleware will continue to work, and you can continue to deploy your site using Middleware. When you upgrade your site to `v12.2` or later, you will need to follow the [upgrade guide](/docs/messages/middleware-upgrade-guide). | ||
|
||
## Useful Links | ||
|
||
- [Middleware Upgrade Guide](/docs/messages/middleware-upgrade-guide) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: Build directory not writeable | ||
--- | ||
|
||
## Why This Error Occurred | ||
|
||
The filesystem does not allow writing to the specified directory. A common cause for this error is starting a [custom server](/docs/pages/building-your-application/configuring/custom-server) in development mode on a production server, for example, [Vercel](https://vercel.com) which doesn't allow you to write to the filesystem after your app is built. | ||
|
||
## Possible Ways to Fix It | ||
|
||
When using a custom server with a server file, for example called `server.js`, make sure you update the scripts key in `package.json` to: | ||
|
||
```json filename="package.json" | ||
{ | ||
"scripts": { | ||
"dev": "node server.js", | ||
"build": "next build", | ||
"start": "NODE_ENV=production node server.js" | ||
} | ||
} | ||
``` | ||
|
||
and the custom server starts Next in production mode when `NODE_ENV` is `production` | ||
|
||
```js filename="server.js" | ||
const dev = process.env.NODE_ENV !== 'production' | ||
const app = next({ dev }) | ||
``` | ||
|
||
## Useful Links | ||
|
||
- [Custom Server documentation + examples](/docs/pages/building-your-application/configuring/custom-server) |
Oops, something went wrong.