Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 3aa8532

Browse files
docs: update README and example with custom error page
1 parent 92da22d commit 3aa8532

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The plugin targets [Next 8 serverless mode](https://nextjs.org/blog/next-8/#serv
2121
- [Deploying a single page](#deploying-a-single-page)
2222
- [Overriding page configuration](#overriding-page-configuration)
2323
- [Custom page routing](#custom-page-routing)
24+
- [Custom 404 error page](#custom-404-error-page)
2425
- [Examples](#examples)
2526

2627
## Motivation
@@ -192,6 +193,22 @@ custom:
192193
slug: true
193194
```
194195

196+
## Custom 404 error page
197+
198+
By default, Amazon API Gateway returns 403 responses when a given route doesn't exist. Instead, the plugin renders the [\_error page](https://nextjs.org/docs/#custom-error-handling). That way you can customise how your 404 error page looks like.
199+
200+
Simply add `pages/_error.js`:
201+
202+
```js
203+
class Error extends React.Component {
204+
render() {
205+
return <p>404 page not found. (╯°□°)╯︵ ┻━┻</p>;
206+
}
207+
}
208+
209+
export default Error;
210+
```
211+
195212
## Examples
196213

197214
See the `examples/` directory.

examples/basic-next-serverless-app/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ module.exports = {
2828

2929
Alternatively, remove `assetPrefix` and the bucket won't be provisioned.
3030

31+
#### Running locally
32+
33+
`npx serverless offline`
34+
3135
#### Deploy
3236

3337
`serverless deploy`

examples/basic-next-serverless-app/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
},
2828
"devDependencies": {
2929
"eslint-plugin-react": "^7.12.4",
30-
"serverless-nextjs-plugin": "^1.1.2"
30+
"serverless": "^1.39.1",
31+
"serverless-nextjs-plugin": "^1.2.0",
32+
"serverless-offline": "^4.9.2"
3133
}
3234
}

examples/basic-next-serverless-app/serverless.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ region: eu-west-1
1010

1111
plugins:
1212
- serverless-nextjs-plugin
13+
- serverless-offline
1314

1415
custom:
1516
serverless-nextjs:

0 commit comments

Comments
 (0)