未验证 提交 e9a1d8fd 编写于 作者: J JJ Kasper 提交者: GitHub

Add documentation for new static 500 behavior (#22888)

Co-authored-by: NTim Neutkens <tim@timneutkens.nl>
Co-authored-by: Nkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
上级 d951b238
......@@ -25,9 +25,22 @@ export default function Custom404() {
## 500 Page
By default Next.js provides a 500 error page that matches the default 404 page’s style. This page is not statically optimized as it allows server-side errors to be reported. This is why 404 and 500 (other errors) are separated.
Server-rendering an error page for every visit adds complexity to responding to errors. To help users get responses to errors as fast as possible, Next.js provides a static 500 page by default without having to add any additional files.
### Customizing The Error Page
### Customizing The 500 Page
To customize the 500 page you can create a `pages/500.js` file. This file is statically generated at build time.
```jsx
// pages/500.js
export default function Custom500() {
return <h1>500 - Server-side error occurred</h1>
}
```
> **Note**: You can use [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation) inside this page if you need to fetch data at build time.
### More Advanced Error Page Customizing
500 errors are handled both client-side and server-side by the `Error` component. If you wish to override it, define the file `pages/_error.js` and add the following code:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册