Fix pathname scope in ssrOG.ts

This commit is contained in:
gpt-engineer-app[bot]
2025-11-06 05:04:38 +00:00
parent b189f40c1f
commit 57ac5c1f1a

View File

@@ -220,10 +220,12 @@ function injectOGTags(html: string, ogTags: string): string {
} }
export default async function handler(req: VercelRequest, res: VercelResponse): Promise<void> { export default async function handler(req: VercelRequest, res: VercelResponse): Promise<void> {
let pathname = '/';
try { try {
const userAgent = req.headers['user-agent'] || ''; const userAgent = req.headers['user-agent'] || '';
const fullUrl = `https://${req.headers.host}${req.url}`; const fullUrl = `https://${req.headers.host}${req.url}`;
const pathname = new URL(fullUrl).pathname; pathname = new URL(fullUrl).pathname;
// Comprehensive bot detection with headers // Comprehensive bot detection with headers
const botDetection = detectBot(userAgent, req.headers as Record<string, string | string[] | undefined>); const botDetection = detectBot(userAgent, req.headers as Record<string, string | string[] | undefined>);