Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 2ffb33a

Browse files
authored
feat: add option "expiration" to extend signed requests (#248)
* HTTPError: Response code 403 (Forbidden) #237 * HTTPError: Response code 403 (Forbidden) #237
1 parent 8f52af0 commit 2ffb33a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ module.exports = {
3434
region: process.env.AWS_REGION,
3535
},
3636
buckets: ["my-bucket", "my-second-bucket"],
37+
expiration: 120,
3738
},
3839
},
3940
],
4041
};
4142
```
4243

44+
The value of expiration specifies the time after which signed requests to S3 will expire. The default value is 60 seconds. Feel free to increase if you have many or large images and start to see errors similar to "HTTPError: Response code 403 (Forbidden)" during build. This option is not compulsory.
45+
4346
### AWS setup
4447

4548
You can use the plugin both with private and public buckets.

src/gatsby-node.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type pluginOptionsType = {
1111
region: string;
1212
};
1313
buckets: string[];
14+
expiration: number;
1415
};
1516

1617
type ObjectType = AWS.S3.Object & { Bucket: string };
@@ -20,7 +21,7 @@ export async function sourceNodes(
2021
{ actions: { createNode }, createNodeId, createContentDigest, reporter },
2122
pluginOptions: pluginOptionsType
2223
) {
23-
const { aws: awsConfig, buckets } = pluginOptions;
24+
const { aws: awsConfig, buckets, expiration = 60 } = pluginOptions;
2425

2526
// configure aws
2627
AWS.config.update(awsConfig);
@@ -91,7 +92,7 @@ export async function sourceNodes(
9192
const url = s3.getSignedUrl("getObject", {
9293
Bucket,
9394
Key,
94-
Expires: 60,
95+
Expires: expiration,
9596
});
9697

9798
createNode({

0 commit comments

Comments
 (0)