fix: use Bun.file().text() at module scope to inline test-api.html

Bun HTML import returns HTMLBundle object on Vercel serverless, which
renders as '[object HTMLBundle]'. Using Bun.file().text() at top-level
module scope ensures Bun bundler inlines the raw string at build time.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-17 13:54:13 +07:00
co-authored by Claude
parent bcba2c5386
commit f8fd18612b
+5 -2
View File
@@ -29,7 +29,10 @@ import { createRateLimiter } from "../src/middleware/rate-limiter";
import { logRelayEvent } from "../src/middleware/logger";
import { handleChatCompletion, listModels } from "../src/lib/ai-proxy";
import { handleAnthropicMessages } from "../src/lib/anthropic-proxy";
import testApiHtml from "../public/test-api.html" with { type: "text" };
// Read test-api.html at module scope so Bun's bundler inlines the content
// at build time (Vercel serverless has no filesystem at runtime).
const testApiHtmlRaw = await Bun.file("public/test-api.html").text();
// ─── Configuration ──────────────────────────────────────────────────────────────
@@ -382,7 +385,7 @@ export default {
// Static routes — show index only when no relay target is requested
if (url.pathname === "/health") return handleHealth();
if (url.pathname === "/docs" || url.pathname === "/test") {
return new Response(testApiHtml, {
return new Response(testApiHtmlRaw, {
headers: { "Content-Type": "text/html; charset=utf-8" },
});
}