From f8fd18612b214905b5ca8e4c530d3ad6911139fb Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Wed, 17 Jun 2026 13:54:13 +0700 Subject: [PATCH] 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 --- api/relay.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/relay.ts b/api/relay.ts index 3490b3b..dd6eee6 100644 --- a/api/relay.ts +++ b/api/relay.ts @@ -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" }, }); }