From f3939c66e42b44ce5df2c91e75add1ebc9c3a1f5 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 4 Mar 2026 09:01:52 -0800 Subject: [PATCH] Fix OG image not rendering on Twitter/social shares Root-level static files (og-image.png, favicon.svg, robots.txt, etc.) were not served because the server only had routes for subdirectories. Add a fetch fallback handler to serve any existing file from public/. Co-Authored-By: Claude Opus 4.6 --- server/index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index c0933dfec..e6d5bf296 100644 --- a/server/index.js +++ b/server/index.js @@ -49,7 +49,18 @@ const server = serve({ } return new Response("Not Found", { status: 404 }); }, - + "/antipattern-examples/*": async (req) => { + const url = new URL(req.url); + const filePath = `./public${url.pathname}`; + const assetFile = file(filePath); + if (await assetFile.exists()) { + return new Response(assetFile, { + headers: { "Content-Type": "text/html" } + }); + } + return new Response("Not Found", { status: 404 }); + }, + // API: Get all skills "/api/skills": { async GET() { @@ -97,6 +108,17 @@ const server = serve({ }, }, + // Serve root-level static files (og-image.png, favicon, robots.txt, etc.) + fetch(req) { + const url = new URL(req.url); + const filePath = `./public${url.pathname}`; + const staticFile = file(filePath); + if (staticFile.size > 0) { + return new Response(staticFile); + } + return new Response("Not Found", { status: 404 }); + }, + development: process.env.NODE_ENV !== "production", });