From 125f27453a7c4b8fc92ac490fd222133cd59a679 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 2 May 2026 13:30:59 +0000 Subject: [PATCH] fix(web): wire DOCS_PROXY_URL into deployed Worker env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every link on stackpanel.com pointing under `/docs/*` (Quick start, Why Stackpanel, Changelog, Stacks, License, …) currently returns HTTP 503 with `{"error":"DOCS_PROXY_URL environment variable is not configured"}`. The proxy route at `apps/web/src/routes/docs/$.ts` + `index.ts` reads `process.env.DOCS_PROXY_URL` and short-circuits with that 503 when the binding is missing. Root cause: the proxy was added on 2026-04-23 (74fca2e "Make environment variables required by default") but `apps/web/alchemy.run.ts` was never updated to forward the URL into `Cloudflare.Vite({ env })`. The recent `feat(env): build-time secret injection` commit established the env- forwarding pattern for `BETTER_AUTH_SECRET` + Polar values but didn't include this one. So the binding has been absent on every deploy since the route landed — the docs site itself (`docs.stackpanel.com`) is healthy, only the apex proxy is broken. Fix: derive `DOCS_PROXY_URL` per stage to mirror `hostnameFor` in `apps/docs/alchemy.run.ts` (production → docs.stackpanel.com, staging → docs.staging.stackpanel.com), and forward it through the same `Cloudflare.Vite({ env })` block the secrets use. PR previews and dev fall back to the production docs site since we don't deploy per-PR docs workers; serving real content is preferable to 503'ing. The CI memo-bust from PR #27 (.build-info stamp) will force a fresh upload on push so this actually reaches the deployed Worker. --- apps/web/alchemy.run.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/web/alchemy.run.ts b/apps/web/alchemy.run.ts index 9af4b760..8709f0d9 100644 --- a/apps/web/alchemy.run.ts +++ b/apps/web/alchemy.run.ts @@ -38,6 +38,20 @@ const program = Effect.gen(function* () { roleName: `${PROJECT}-${SERVICE}-owner`, }); + // Where the worker's `/docs/*` proxy (apps/web/src/routes/docs/$.ts, + // index.ts) forwards requests. Mirrors `hostnameFor` in + // apps/docs/alchemy.run.ts so each stage proxies to its own docs + // deployment; PR previews and dev fall back to the production docs site + // since we don't deploy a per-PR docs Worker. Without this binding the + // route handler returns 503 ("DOCS_PROXY_URL environment variable is not + // configured") for every /docs link on the marketing page. + const docsProxyUrl = + stage === "production" + ? "https://docs.stackpanel.com" + : stage === "staging" + ? "https://docs.staging.stackpanel.com" + : "https://docs.stackpanel.com"; + // Forward the runtime secrets we just decrypted via `loadDeployEnv` into // the Cloudflare Worker's environment. These are ALREADY decrypted at // deploy time (the `loadDeployEnv("web", appEnv)` call above pulls the @@ -66,6 +80,7 @@ const program = Effect.gen(function* () { process.env.POLAR_PRO_PRODUCT_ID_PRODUCTION ?? "", POLAR_FREE_PRODUCT_ID_PRODUCTION: process.env.POLAR_FREE_PRODUCT_ID_PRODUCTION ?? "", + DOCS_PROXY_URL: docsProxyUrl, }, }); let url: Output.Output = website.url;