fix: serve test-api.html at /docs on Vercel and Worker deployments

Update api/relay.ts (Vercel entry point) and src/worker.ts (Cloudflare
Workers entry point) to serve the interactive API test console at /docs
and /test, replacing the old inline docs page.

api/relay.ts uses Bun's HTML import (bundled inline at build time)
since filesystem access is unavailable in Vercel serverless runtime.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-17 13:37:23 +07:00
co-authored by Claude
parent aa3f96ef2d
commit bc6edbef3e
2 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -386,7 +386,14 @@ export default {
const url = new URL(req.url);
if (url.pathname === "/health") return handleHealth();
if (url.pathname === "/docs") return handleDocs();
if (url.pathname === "/docs" || url.pathname === "/test") {
const file = Bun.file("public/test-api.html");
const exists = await file.exists();
return new Response(exists ? file : "Not found", {
status: exists ? 200 : 404,
headers: { "Content-Type": "text/html; charset=utf-8" },
});
}
if (
url.pathname === "/" &&
req.method === "GET" &&