You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(next/image): improve and simplify detect-content-type (#82118)
Add support for detecting more src image formats via magic number. The
src image formats are handled as follows:
- `image/jxl` - serve as is (since safari can render it)
- `image/heic` - serve as is (since safari can render it)
- `image/jp2` - serve as is (since safari can render it)
- `application/pdf` - error (since no browser will render it)
- `image/pic` - error (since no browser will render it)
We also fallback to `sharp().metadata()` if we can't detect the magic
number to ensure correctness.
`The requested resource "${href}" is an animated image so it will not be optimized. Consider adding the "unoptimized" property to the <Image>.`
728
-
)
729
-
}
730
-
return{
731
-
buffer: upstreamBuffer,
732
-
contentType: upstreamType,
733
-
maxAge,
734
-
etag: upstreamEtag,
735
-
upstreamEtag,
736
-
}
796
+
thrownewImageError(400,"The requested resource isn't a valid image.")
797
+
}
798
+
if(
799
+
upstreamType.startsWith('image/svg')&&
800
+
!nextConfig.images.dangerouslyAllowSVG
801
+
){
802
+
if(!opts.silent){
803
+
Log.error(
804
+
`The requested resource "${href}" has type "${upstreamType}" but dangerouslyAllowSVG is disabled. Consider adding the "unoptimized" property to the <Image>.`
805
+
)
737
806
}
738
-
if(BYPASS_TYPES.includes(upstreamType)){
739
-
return{
740
-
buffer: upstreamBuffer,
741
-
contentType: upstreamType,
742
-
maxAge,
743
-
etag: upstreamEtag,
744
-
upstreamEtag,
745
-
}
807
+
thrownewImageError(
808
+
400,
809
+
'"url" parameter is valid but image type is not allowed'
0 commit comments