perf: bypass Worker for static routes

This commit is contained in:
ibelick
2026-08-28 17:21:55 +02:00
parent 2666ceb9f6
commit f2dadf221a
5 changed files with 31 additions and 1 deletions
+4
View File
@@ -13,6 +13,10 @@
/analytics/*
Cache-Control: public, max-age=3600
/mcp.json
Cache-Control: public, max-age=300, s-maxage=3600, stale-while-revalidate=86400
Content-Type: application/json; charset=utf-8
/_astro/*
Cache-Control: public, max-age=31536000, immutable
+8
View File
@@ -0,0 +1,8 @@
{
"name": "UI Skills MCP",
"version": "0.2.4",
"protocol": "mcp",
"endpoint": "https://www.ui-skills.com/mcp",
"registry": "https://www.ui-skills.com/skills/registry.json",
"tools": ["list_skills", "get_skill"]
}
+2
View File
@@ -1,6 +1,8 @@
import type { APIRoute } from "astro";
import { getGithubStars } from "../../lib/github-stars.ts";
export const prerender = true;
export const GET: APIRoute = async () => {
const stars = await getGithubStars();
return Response.json(stars, {
+15
View File
@@ -123,6 +123,21 @@ try {
throw new Error("First-party One Dollar Stats script is missing");
}
const mcpMetadata = await fetchLocal("/mcp.json");
if (mcpMetadata.status !== 200) {
throw new Error(`Static MCP metadata returned ${mcpMetadata.status}`);
}
const mcpMetadataType = mcpMetadata.headers.get("content-type") ?? "";
if (!mcpMetadataType.startsWith("application/json")) {
throw new Error(`Static MCP metadata returned unexpected type: ${mcpMetadataType}`);
}
if (mcpMetadata.headers.get("cache-control") === null) {
throw new Error("Static MCP metadata is missing cache headers");
}
if (!(await mcpMetadata.text()).includes('"UI Skills MCP"')) {
throw new Error("Static MCP metadata is invalid");
}
const analyticsProxy = await fetchLocal("/analytics/events", {
method: "POST",
headers: { "Content-Type": "application/json" },
+2 -1
View File
@@ -6,9 +6,10 @@
"directory": "./dist",
"binding": "ASSETS",
"not_found_handling": "404-page",
"html_handling": "drop-trailing-slash",
"run_worker_first": [
"/api/*",
"/mcp",
"/mcp/rpc",
"/oauth/*",
"/_server-islands/*",
"/_image",