Skip to content

fix: prefer plain SERVER_API_TOKEN over the Secrets Store binding at build time - #17

Merged
colinmcdonald22 merged 1 commit into
LunarClient:devfrom
imconnorngl:fix/prerender-server-api-token
Sep 13, 2026
Merged

colinmcdonald22 merged 1 commit into
LunarClient:devfrom
imconnorngl:fix/prerender-server-api-token

Conversation

@imconnorngl

Copy link
Copy Markdown
Member

Summary

Fixes the failing Deploy Workers run on dev: https://github.com/LunarClient/SkyCrypt/actions/runs/34767441597/job/103751131850

During vite build the Cloudflare platform proxy exposes SERVER_API_TOKEN as a local Secrets Store binding for the selected CLOUDFLARE_ENV. Its get() fails with Secret "skycrypt-server-api-key" not found because the secret only exists in Cloudflare, which broke prerendering and made getAllStats return 500.

Changes

  • Read SERVER_API_TOKEN from $env/dynamic/private first and only fall back to event.platform.env. Local dev and prerender get the plain string from the environment (restoring the pre-feat: bind SERVER_API_TOKEN from Secrets Store #16 build behaviour); deployed Workers still receive the Secrets Store binding through the same env and go through the .get() branch.
  • Cast the dynamic env value to the existing App.Platform type so the .get() branch type-checks, and fall back to an empty token if neither source is present.

Testing

  • pnpm check and oxfmt pass.
  • Full pnpm build was not run locally because prerender requires the live API.

Note

The failing run's log shows the SERVER_API_TOKEN secret as blank rather than masked in the cloudflare-production environment. Prerender built fine that way before #16, so it should not block this change, but it may be worth setting.

…build time

During `vite build` the Cloudflare platform proxy exposes SERVER_API_TOKEN
as a local Secrets Store binding whose get() fails with
`Secret "skycrypt-server-api-key" not found`, breaking prerendering in CI.
Read the dynamic env first (the plain string in dev/prerender, the binding
in deployed Workers) and only fall back to event.platform.env.
@colinmcdonald22
colinmcdonald22 merged commit 06ce645 into LunarClient:dev Sep 13, 2026
5 checks passed
@imconnorngl
imconnorngl deleted the fix/prerender-server-api-token branch September 13, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants