diff --git a/api/ssrOG.ts b/api/ssrOG.ts index 9e3082ce..dda23d95 100644 --- a/api/ssrOG.ts +++ b/api/ssrOG.ts @@ -220,10 +220,12 @@ function injectOGTags(html: string, ogTags: string): string { } export default async function handler(req: VercelRequest, res: VercelResponse): Promise { + let pathname = '/'; + try { const userAgent = req.headers['user-agent'] || ''; const fullUrl = `https://${req.headers.host}${req.url}`; - const pathname = new URL(fullUrl).pathname; + pathname = new URL(fullUrl).pathname; // Comprehensive bot detection with headers const botDetection = detectBot(userAgent, req.headers as Record);