@@ -16,7 +16,7 @@ export type RemotePattern = {
16
16
export function fetchImage ( fetcher : Fetcher | undefined , imageUrl : string ) {
17
17
// https://github.com/vercel/next.js/blob/d76f0b1/packages/next/src/server/image-optimizer.ts#L208
18
18
if ( ! imageUrl || imageUrl . length > 3072 || imageUrl . startsWith ( "//" ) ) {
19
- return new Response ( "Not Found " , { status : 404 } ) ;
19
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
20
20
}
21
21
22
22
// Local
@@ -26,10 +26,10 @@ export function fetchImage(fetcher: Fetcher | undefined, imageUrl: string) {
26
26
const url = new URL ( imageUrl , "http://n" ) ;
27
27
pathname = decodeURIComponent ( url . pathname ) ;
28
28
} catch {
29
- return new Response ( "Not Found " , { status : 404 } ) ;
29
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
30
30
}
31
31
if ( / \/ _ n e x t \/ i m a g e ( $ | \/ ) / . test ( pathname ) ) {
32
- return new Response ( "Not Found " , { status : 404 } ) ;
32
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
33
33
}
34
34
35
35
return fetcher ?. fetch ( `http://assets.local${ imageUrl } ` ) ;
@@ -40,15 +40,15 @@ export function fetchImage(fetcher: Fetcher | undefined, imageUrl: string) {
40
40
try {
41
41
url = new URL ( imageUrl ) ;
42
42
} catch {
43
- return new Response ( "Not Found " , { status : 404 } ) ;
43
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
44
44
}
45
45
46
46
if ( url . protocol !== "http:" && url . protocol !== "https:" ) {
47
- return new Response ( "Not Found " , { status : 404 } ) ;
47
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
48
48
}
49
49
50
50
if ( ! __IMAGES_REMOTE_PATTERNS__ . some ( ( p : RemotePattern ) => matchRemotePattern ( p , url ) ) ) {
51
- return new Response ( "Not Found " , { status : 404 } ) ;
51
+ return new Response ( "Unsupported image config " , { status : 400 } ) ;
52
52
}
53
53
54
54
return fetch ( imageUrl , { cf : { cacheEverything : true } } ) ;
0 commit comments