Image do not show AWS S3 images - "url" parameter is valid but upstream response is invalid
See original GitHub issueWhat version of Next.js are you using?
12.0.2, 12.0.7
What version of Node.js are you using?
16.13.0
What browser are you using?
Chrome
What operating system are you using?
Linux
How are you deploying your application?
next start
Describe the Bug
Possible duplication of https://github.com/vercel/next.js/issues/31377 Showing protected images from AWS S3 resulting with error:
"url" parameter is valid but upstream response is invalid
The s3 bucket policy:
{
"Version": "2012-10-17",
"Id": "http referer policy example",
"Statement": [
{
"Sid": "Allow get requests originating from domainss",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion"
],
"Resource": "arn:aws:s3:::web/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://localhost:3000/*"
]
}
}
}
]
}
nextjs config:
images: {
domains: [
'localhost',
'web.s3.eu-west-1.amazonaws.com'
],
},
Code:
<Image src={`${assets}/img/home-page/plugins.png`} width="800" height="470" alt="Plugins" />
Only way to make it work is by adding the unoptimized={true}
for Image
.
Expected Behavior
Show optimized Image from aws S3
To Reproduce
Use code from the description.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
How to load protected S3 images with Next.js ... - Stack Overflow
The images are fetched through presigned urls. ... I get the following error: "url" parameter is valid but upstream response is invalid ....
Read more >S3 Protected images with Image component. : r/nextjs - Reddit
The images are fetched through presigned urls. ... I get the following error: `"url" parameter is valid but upstream response is invalid`.
Read more >Troubleshoot images not loading in CloudFront - AWS
To resolve this issue, check the Content-Type metadata. If needed, update the value to image/png for the images in an S3 or custom...
Read more >Request and response behavior for Amazon S3 origins
Caching duration and minimum TTL. To control how long your objects stay in a CloudFront cache before CloudFront forwards another request to your...
Read more >Caching content based on query string parameters
The pictures that you have of the jacket show the different colors but not the different sizes. To optimize caching, you should configure...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to create a new Discussion to discuss this idea further.
We would want to see more about how users would use this feature before implementing. Some topics of discussion:
Referrer
be hardcoded or should it be forwarded so it matches the browser?User-Agent
?This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.