From 261ab7b68a2064d6540c116ebe219d3f9b515b52 Mon Sep 17 00:00:00 2001 From: honbin Date: Thu, 29 Oct 2026 22:54:28 +0900 Subject: [PATCH] Skip Open Graph tags on error pages Missing paths returned 500 in dev instead of 404: the middleware tagged Void's 404 page too, and addOgTags throws because that page's title has no site suffix. Error pages are not shared, so only successful responses get the tags. --- middleware/01.og.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleware/01.og.ts b/middleware/01.og.ts index 377760c..e1c43b2 100644 --- a/middleware/01.og.ts +++ b/middleware/01.og.ts @@ -5,7 +5,8 @@ import { placeImage, placeImagePaths, siteName, siteUrl, titleSuffix } from "#sr export default defineMiddleware(async (c, next) => { await next(); - if (!c.res.headers.get("content-type")?.includes("text/html")) return; + // Error pages come from Void, without the site's title suffix, and are not shared. + if (!c.res.ok || !c.res.headers.get("content-type")?.includes("text/html")) return; const path = c.req.path.endsWith("/") ? c.req.path : `${c.req.path}/`; const record = records.find((r) => r.path === path);