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

Commit 411573f

Browse files
docs: update with new routes configuration object
1 parent 6523b5e commit 411573f

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

README.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The plugin targets [Next 8 serverless mode](https://nextjs.org/blog/next-8/#serv
2323
- [Custom page routing](#custom-page-routing)
2424
- [Custom error page](#custom-error-page)
2525
- [Custom lambda handler](#custom-lambda-handler)
26+
- [All plugin configuration options](#all-plugin-configuration-options)
2627
- [Examples](#examples)
2728
- [Contributing](#contributing)
2829

@@ -120,11 +121,19 @@ custom:
120121

121122
With this approach you could have a CloudFront distribution in front of the bucket and use a custom domain in the assetPrefix.
122123

123-
| Plugin config key | Default Value | Description |
124-
| ----------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
125-
| assetsBucketName | \<empty\> | Creates an S3 bucket with the name provided. The bucket will be used for uploading next static assets |
126-
| staticDir | \<empty\> | Directory with static assets to be uploaded to S3, typically a directory named `static`, but it can be any other name. Requires a bucket provided via the `assetPrefix` described above or the `assetsBucketName` plugin config. |
127-
| uploadBuildAssets | true | In the unlikely event that you only want to upload the `staticDir`, set this to `false` |
124+
If you need the static assets available in the main domain of your application, you can use the `routes` configuration to proxy API Gateway requests to S3. For example, to host `/robots.txt`:
125+
126+
```yml
127+
custom:
128+
serverless-nextjs:
129+
nextConfigDir: ./
130+
staticDir: ./assets
131+
routes:
132+
- src: ./assets/robots.txt
133+
path: robots.txt
134+
```
135+
136+
Note that for this to work, an S3 bucket needs to be provisioned by using the `assetsBucketName` plugin config or `assetPrefix` in `next.config.js`.
128137

129138
## Deploying
130139

@@ -217,7 +226,7 @@ E.g.
217226
| pages/blog/index.js | /blog |
218227
| pages/categories/uno/dos.js | /categories/uno/dos |
219228

220-
You may want to serve your page from a different path. This is possible by setting your own http path in the `pageConfig`. For example for `pages/post.js`:
229+
You may want to serve your page from a different path. This is possible by setting your own http path in the `routes` config. For example for `pages/post.js`:
221230

222231
```js
223232
class Post extends React.Component {
@@ -241,15 +250,13 @@ plugins:
241250
custom:
242251
serverless-nextjs:
243252
nextConfigDir: ./
244-
pageConfig:
245-
post:
246-
events:
247-
- http:
248-
path: post/{slug}
249-
request:
250-
parameters:
251-
paths:
252-
slug: true
253+
routes:
254+
- src: post
255+
path: foo/{slug}
256+
request:
257+
parameters:
258+
paths:
259+
slug: true
253260
```
254261

255262
## Custom error page
@@ -311,6 +318,16 @@ module.exports = page => {
311318
};
312319
```
313320

321+
## All plugin configuration options
322+
323+
| Plugin config key | Default Value | Description |
324+
| ----------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
325+
| nextConfigDir | \<empty\> | Path to parent directory of `next.config.js` |
326+
| assetsBucketName | \<empty\> | Creates an S3 bucket with the name provided. The bucket will be used for uploading next static assets |
327+
| staticDir | \<empty\> | Directory with static assets to be uploaded to S3, typically a directory named `static`, but it can be any other name. Requires a bucket provided via the `assetPrefix` described above or the `assetsBucketName` plugin config. |
328+
| routes | [] | Array of custom routes for the next pages or static assets. |
329+
| uploadBuildAssets | true | In the unlikely event that you only want to upload the `staticDir`, set this to `false` Note it expects `nextConfigDir` to be a directory and not the actual file path. |
330+
314331
## Examples
315332

316333
See the `examples/` directory.

0 commit comments

Comments
 (0)