Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image optimization incorrectly returns 400 #23837

Closed
fulopdaniel opened this issue Apr 8, 2021 · 5 comments
Closed

Image optimization incorrectly returns 400 #23837

fulopdaniel opened this issue Apr 8, 2021 · 5 comments
Labels
bug Issue was opened via the bug report template.

Comments

@fulopdaniel
Copy link

fulopdaniel commented Apr 8, 2021

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

v12.18.3

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

When supplying an AWS S3 URL to the Image component from next/image, an error is returned from the server saying "The requested resource isn't a valid image.".

This is a new feature, introduced in this commit:
9821140

However the content type of an image coming from S3 in my case is 'binary/octet-stream', so 400 status code is returned, because it does not start with "image/", and the picture does not load.

Using Next.js@10.0.1 does load the image, or using a simple img tag also works.

Expected Behavior

The image should be loaded.

To Reproduce

import Image from 'next/image';

<Image src={<INSERT_S3_URL>} height={200} width={100} />

@fulopdaniel fulopdaniel added the bug Issue was opened via the bug report template. label Apr 8, 2021
@ElvisWong
Copy link

You can change the metadata in headers of your image in S3 from application/octlet-stream to image/jpeg. That will solve the problem.

image

image

@fulopdaniel
Copy link
Author

Yes, but it is not possible in every scenario. For example we are using presigned URLs to upload the pictures, and I believe it is not possible to set the content-type automatically with that approach.

@shuding
Copy link
Member

shuding commented Apr 13, 2021

Closing as duplicate of #23523.

@shuding shuding closed this as completed Apr 13, 2021
@jonahallibone
Copy link

@fulopdaniel it is

Yes, but it is not possible in every scenario. For example we are using presigned URLs to upload the pictures, and I believe it is not possible to set the content-type automatically with that approach.

@fulopdaniel It is, just send it along in the header of the request, or in the options object when creating the presigned URL

@balazsorban44
Copy link
Member

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.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

5 participants