aws-amplify / aws-amplify/amplify-hosting
Persisting nextJS image cache
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting questions](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
d3qrlpiuwokaxd
### AWS Region
ap-southeast-2
### Amplify Hosting feature
Git providers, Monorepo, SSR
### Question
I have a nextJS 13.2.1 setup with git delpoyment from a mono repo with a backend auth and storage s3 configured for. Everything works fine and as expected but I loose all my nextJS generated/cached images with every new deployment as is expected. I understand that nextJS allows for a custom path to be set for it's image cache through next.config file for specifically this reason:
```js
const config = {
output: 'standalone',
images: {
minimumCacheTTL: 3_153_600_000,
formats: ['image/avif', 'image/webp'],
domains: [
...,
],
loader: 'default',
path: 'MY_CUSTOM_IMAGE_CACHE_PATH',
},
}
export default config;
```
What I do not have a knowledge for and can't find any resources about is how I can use my already setup storage s3 bucket or a new one if need be, to be used for this purpose. If I use the path to my s3 bucket here, unsurpirsingly I get 403s for images.
Thanks fir your helps
Contributor guide
Research direction
Start with the Next.js 13.2.1 image configuration in next.config and the Amplify Hosting SSR/monorepo deployment setup described here. Check how the configured image path is interpreted during deployment and how the existing S3 storage is authorized; done means a deployment can reuse generated images without 403s.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, nextjs
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100