Skip to content

Forward Wrangler config vars to astro:env#17275

Draft
matthewp wants to merge 1 commit into
mainfrom
cloudflare-wrangler-vars
Draft

Forward Wrangler config vars to astro:env#17275
matthewp wants to merge 1 commit into
mainfrom
cloudflare-wrangler-vars

Conversation

@matthewp

@matthewp matthewp commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #16790

Changes

  • astro:env public variables defined under vars in a Wrangler config (wrangler.toml/.json/.jsonc) now resolve when imported from astro:env/client and astro:env/server. Previously only .dev.vars was loaded into the environment, so public vars were inlined as undefined at build time (only getSecret worked).
  • The adapter reads vars via wrangler's unstable_readConfig in astro:config:done and assigns them to process.env, respecting CLOUDFLARE_ENV. Using wrangler's own reader covers TOML/JSON/JSONC and does the same env merging wrangler does at runtime. .dev.vars is loaded afterwards so it still takes precedence.

Testing

  • Removed the manual process.env.API_URL/process.env.PORT overrides from astro-env SSR tests. Those overrides were masking the bug; the tests now rely on the adapter loading vars from the fixture's wrangler.jsonc, exercising the real code path for both build and dev.

Docs

  • No docs update needed; this makes the adapter match the already-documented astro:env behavior.

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 389dd27

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@astrojs/cloudflare Patch
@test/astro-cloudflare-node-prerender-mdx Patch
@test/astro-cloudflare Patch
@test/astro-cloudflare-allowed-hosts Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-binding-image-service Patch
@test/astro-cloudflare-cache-provider-wait-until Patch
@test/astro-cloudflare-cache-provider Patch
@test/astro-cloudflare-client-address Patch
@test/astro-cloudflare-compile-custom-image-service Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-dev-image-endpoint Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-external-redirects Patch
@test/astro-cloudflare-internal-redirects Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-prerender-queue-consumers Patch
@test/astro-cloudflare-prerender-styles Patch
@test/astro-cloudflare-prerenderer-errors Patch
@test/astro-cloudflare-prerenderer-render-error Patch
@test/routing-priority-cloudflare Patch
@test/cf-server-entry Patch
@test/astro-cloudflare-server-island-prerender-framework Patch
@test/astro-cloudflare-sessions Patch
@test/astro-cloudflare-sql-import Patch
@test/cf-ssr-deps Patch
@test/astro-cloudflare-static Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-top-level-return Patch
@test/cf-user-optimize-deps Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-react Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@astrojs/cloudflare doesn't correctly forward wrangler vars to Astro

1 participant