question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image do not show AWS S3 images - "url" parameter is valid but upstream response is invalid

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
styflecommented, Dec 8, 2021

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:

  • Should Referrer be hardcoded or should it be forwarded so it matches the browser?
  • Are there other headers that should be assigned such as User-Agent?
  • Whats preventing other proxies from mimicking these headers to retrieve the source image? (not a real form of security IMO)
0reactions
balazsorban44commented, Jan 27, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found