Vercel OG
Unanswered
Haddock posted this in #help-forum
HaddockOP
Hi, i'm using Node 22.12.0 and Next JS 15, when using this code passing the title it returns the following error:
GET /api/og 500 in 234ms
⨯ [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE',
page: '/api/og'
}
But when passing the title as raw text, works fine, what could be happening? Thanks
GET /api/og 500 in 234ms
⨯ [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE',
page: '/api/og'
}
But when passing the title as raw text, works fine, what could be happening? Thanks
import { ImageResponse } from 'next/og';
// App router includes @vercel/og.
// No need to install it.
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
// ?title=<title>
const hasTitle = searchParams.has('title');
const title = hasTitle
? searchParams.get('title')?.slice(0, 100)
: 'My default title';
return new ImageResponse(
(
<div
style={{
fontSize: 40,
color: 'black',
background: 'white',
width: '100%',
height: '100%',
padding: '50px 200px',
textAlign: 'center',
justifyContent: 'center',
alignItems: 'center',
}}
>
{title}
</div>
),
{
width: 1200,
height: 630,
}
);
}
1 Reply
HaddockOP