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:
+5
-2
@@ -29,7 +29,10 @@ import { createRateLimiter } from "../src/middleware/rate-limiter";
|
|||||||
import { logRelayEvent } from "../src/middleware/logger";
|
import { logRelayEvent } from "../src/middleware/logger";
|
||||||
import { handleChatCompletion, listModels } from "../src/lib/ai-proxy";
|
import { handleChatCompletion, listModels } from "../src/lib/ai-proxy";
|
||||||
import { handleAnthropicMessages } from "../src/lib/anthropic-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 ──────────────────────────────────────────────────────────────
|
// ─── Configuration ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -382,7 +385,7 @@ export default {
|
|||||||
// Static routes — show index only when no relay target is requested
|
// Static routes — show index only when no relay target is requested
|
||||||
if (url.pathname === "/health") return handleHealth();
|
if (url.pathname === "/health") return handleHealth();
|
||||||
if (url.pathname === "/docs" || url.pathname === "/test") {
|
if (url.pathname === "/docs" || url.pathname === "/test") {
|
||||||
return new Response(testApiHtml, {
|
return new Response(testApiHtmlRaw, {
|
||||||
headers: { "Content-Type": "text/html; charset=utf-8" },
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user