mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
517fcfe47e
commit
f3939c66e4
+23
-1
@@ -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",
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user