You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
| 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`.
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`:
221
230
222
231
```js
223
232
class Post extends React.Component {
@@ -241,15 +250,13 @@ plugins:
241
250
custom:
242
251
serverless-nextjs:
243
252
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
253
260
```
254
261
255
262
## Custom error page
@@ -311,6 +318,16 @@ module.exports = page => {
311
318
};
312
319
```
313
320
321
+
## All plugin configuration options
322
+
323
+
| Plugin config key | Default Value | Description |
| 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. |
0 commit comments