Skip to content

Commit

Permalink
Merge branch 'master' into feat/homepage-revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas authored Oct 9, 2024
2 parents bda6f26 + 0b42cce commit f3e2eae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/web/app/frames/img-proxy/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export async function GET(request: NextRequest) {
throw new Error(`Failed to fetch image: ${response.statusText}`);
}
const contentType = response.headers.get('content-type');

if (!contentType || !contentType.startsWith('image') || contentType.includes('svg')) {
return NextResponse.json({ error: 'Unsupported content type' }, { status: 400 });
}

const imageBuffer = await response.arrayBuffer();
return new NextResponse(imageBuffer, {
status: 200,
Expand All @@ -23,7 +28,6 @@ export async function GET(request: NextRequest) {
},
});
} catch (error) {
console.error('Error fetching image:', error);
return NextResponse.json({ error: 'Failed to fetch image' }, { status: 500 });
}
}

0 comments on commit f3e2eae

Please sign in to comment.