@@ -15,7 +15,7 @@ export async function GET(request: Request) {
1515 // Add appropriate headers for fetching images
1616 const response = await fetch ( imageUrl , {
1717 headers : {
18- ' Accept' : 'image/*, */*' ,
18+ Accept : 'image/*, */*' ,
1919 'User-Agent' : 'Mozilla/5.0 (compatible; ImageProxyBot/1.0)' ,
2020 } ,
2121 // Set a reasonable timeout
@@ -24,17 +24,17 @@ export async function GET(request: Request) {
2424
2525 if ( ! response . ok ) {
2626 console . error ( `Failed to fetch image from ${ imageUrl } :` , response . status , response . statusText )
27- return new NextResponse ( `Failed to fetch image: ${ response . status } ${ response . statusText } ` , {
28- status : response . status
27+ return new NextResponse ( `Failed to fetch image: ${ response . status } ${ response . statusText } ` , {
28+ status : response . status ,
2929 } )
3030 }
3131
3232 const contentType = response . headers . get ( 'content-type' )
3333 console . log ( 'Image content-type:' , contentType )
34-
34+
3535 const blob = await response . blob ( )
3636 console . log ( 'Image size:' , blob . size , 'bytes' )
37-
37+
3838 if ( blob . size === 0 ) {
3939 console . error ( 'Empty image received from source URL' )
4040 return new NextResponse ( 'Empty image received from source' , { status : 422 } )
@@ -52,11 +52,11 @@ export async function GET(request: Request) {
5252 } catch ( error ) {
5353 // Log the full error for debugging
5454 console . error ( 'Error proxying image:' , error )
55-
55+
5656 // Return a helpful error response
5757 return new NextResponse (
58- `Internal Server Error: ${ error instanceof Error ? error . message : 'Unknown error' } ` ,
58+ `Internal Server Error: ${ error instanceof Error ? error . message : 'Unknown error' } ` ,
5959 { status : 500 }
6060 )
6161 }
62- }
62+ }
0 commit comments