import { ImageResponse } from '@vercel/og'; import { NextRequest } from 'next/server'; export const runtime = 'edge'; export async function GET(req: NextRequest) { try { const { searchParams } = new URL(req.url); const width = parseInt(searchParams.get('width') || '400'); const height = parseInt(searchParams.get('height') || '250'); if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) { return new Response('Invalid dimensions', { status: 400 }); } return new ImageResponse( (
{`${width} × ${height}`}
), { width, height, }, ); } catch (e) { console.error(e); return new Response('Failed to generate image', { status: 500 }); } }