From 1bb01f31d2b238dbb37ce5f4cf298c25a811a770 Mon Sep 17 00:00:00 2001 From: lifeodyssey Date: Tue, 16 Jun 2026 23:32:40 +0800 Subject: [PATCH 1/2] perf: inline Supabase config to eliminate initial fetch delay Worker now injects SUPABASE_URL and SUPABASE_PUBLISHABLE_KEY into the HTML response via a `; + const html = await response.text(); + const injected = html.replace("", `${configScript}`); + return new Response(injected, { + status: response.status, + statusText: response.statusText, + headers: response.headers + }); +} + function discoveryRoute(request: Request, url: URL): Response | null { if (request.method !== "GET" && request.method !== "HEAD") { return null; From fed4342b9c6f142ca9e05869d96fd14509a87a6b Mon Sep 17 00:00:00 2001 From: lifeodyssey Date: Tue, 16 Jun 2026 23:39:46 +0800 Subject: [PATCH 2/2] docs: add JSDoc to injectConfig --- src/worker/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/worker/index.ts b/src/worker/index.ts index 3631a9e..c45f59d 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -153,6 +153,11 @@ export default { } }; +/** + * Injects the Supabase client config into an HTML response so the browser + * can initialise the Supabase client without a separate /api/config fetch. + * The injected script sets window.__APP_CONFIG__ before any module scripts run. + */ async function injectConfig(response: Response, env: Env): Promise { const configScript = `