-
Notifications
You must be signed in to change notification settings - Fork 86
Images generated by next/image not in optimized formats and have 301 redirect issue #687
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
Comments
Confirming that this is still an issue with v4 of the plugin, as mentioned by OP here. As an example, we'll have an image in our app like this: import Image from "next/image"
import Error404Image from "./404.png"
const MyComponent = () => {
return <Image src={Error404Image} />
} At runtime we see a request to And the server responds with a 301 redirect to Looking at the docs for ipx, I can force the conversion to webp by add So it should be (🤞) relatively minimal new logic needed in the handler to check the user-agent/client hints and use the most optimized format it supports (i.e. webp or avif). |
Hello I'm seeing this issue as well, where can I check the status of the fix implementation if any? |
Hi. There is experimental support now, using Edge Functions. If you set the env var |
Thanks for the quick response. I can verify that by enabling the env var the redirects are gone and file format optimization works. |
Hi @maxtechera, did you ever figure out a solution when setting Experiencing the same - redirects are gone, but not all images are loading due to timeouts. |
Hey @austinlangdon - I've seen on answers.netlify.com that when a source image is large enough for it to take the edge function more than 10s (their max length) to transcode the image, they time out and cut off. The advice was to reduce the size of the original image, though I wasn't able to reduce the size enough to get under the timeout threshold. |
@hughrawlinson scaling down the image size fixed the issue. Thank you! |
I think disabling AVIF could fix it, because that takes a lot longer than other formats. I'll open an issue to add support for that. |
Closing this because the original issue is fixed with edge functions |
Describe the bug
Images generated by next/image 1) are not in optimized webp format despite using webp-compatible browsers (the resultant format is jpeg which is the original image format) and 2) have a strange 301 redirect issue. I tested this in the latest versions of Firefox, Chrome and Safari and error number 2 manifests slightly differently in each browser - in the worst case (Firefox), the transferred 301 file have the same size as the original image, leading to x2 KBs being transferred (and visually-apparent slowness in loading images) whereas in the best case (Safari), the 301 files seem to have 0Bs.
I also tested this both in localhost and in Vercel and none of the above two errors appear in those scenarios.
The image below shows both of these errors in Firefox browser:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Images should be in optimized webp formats and should not have a 301 redirection as in the below image (which is from localhost).
Versions
If you're using the CLI to build
The text was updated successfully, but these errors were encountered: