Skip to content

fix: set Pages Function API_URL via Cloudflare API before deployment#25

Merged
pkmaster21 merged 1 commit intomainfrom
fix/pages-api-url-env
Apr 16, 2026
Merged

fix: set Pages Function API_URL via Cloudflare API before deployment#25
pkmaster21 merged 1 commit intomainfrom
fix/pages-api-url-env

Conversation

@pkmaster21
Copy link
Copy Markdown
Owner

Problem

The env: API_URL: key in the wrangler-action step only sets a shell environment variable for the wrangler process — it has no effect on the Cloudflare Pages Function's runtime environment. As a result, env.API_URL inside the Function was either undefined (returning 502) or stale from a previous dashboard setting, causing the proxy to fail.

Fix

Added a curl step before deployment that PATCHes the Cloudflare Pages project via the API to set API_URL as a production environment variable. This ensures the correct API Gateway URL is always in sync with the PROD_API_GATEWAY_URL secret before each deployment.

The no-op env: API_URL: on the wrangler-action step has been removed.

The env: key in the wrangler-action step only sets shell environment
variables for the wrangler process — it does not configure Cloudflare
Pages Function runtime environment variables. Added an explicit PATCH
call to the Cloudflare Pages API to set API_URL before deploying, so
the proxy function correctly resolves the upstream API Gateway URL.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 16, 2026

Deploying tabby with  Cloudflare Pages  Cloudflare Pages

Latest commit: e29b0bb
Status: ✅  Deploy successful!
Preview URL: https://c61c2618.tabby.pages.dev
Branch Preview URL: https://fix-pages-api-url-env.tabby.pages.dev

View logs

@pkmaster21 pkmaster21 merged commit 3a2f26b into main Apr 16, 2026
7 checks passed
@pkmaster21 pkmaster21 deleted the fix/pages-api-url-env branch April 16, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant