-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[wrangler] Add CF_PAGES environment variables to pages dev #12473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+236
−44
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fe936e5
[wrangler] Add CF_PAGES environment variables to pages dev
petebacondarwin ebf94fb
PR review fixups
petebacondarwin d3109de
fixup
petebacondarwin ac43d13
fix: show actual values for CF_PAGES vars in bindings table
petebacondarwin 0abd976
fix: use correct CF_PAGES_URL format (commit preview URL)
petebacondarwin c3ad204
fix: normalize CF_PAGES_URL in e2e test snapshot
petebacondarwin 3b8aa1d
normalize whitespace in the snapshot to make it more resilient to cha…
petebacondarwin fcce9ee
fix: update e2e snapshots to include CF_PAGES env vars in bindings ou…
petebacondarwin 872d202
tweak comment
petebacondarwin e8e6928
fixup from PR review
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Add CF_PAGES environment variables to `wrangler pages dev` | ||
|
|
||
| `wrangler pages dev` now automatically injects Pages-specific environment variables (`CF_PAGES`, `CF_PAGES_BRANCH`, `CF_PAGES_COMMIT_SHA`, `CF_PAGES_URL`) for improved dev/prod parity. This enables frameworks like SvelteKit to auto-detect the Pages environment during local development. | ||
|
|
||
| - `CF_PAGES` is set to `"1"` to indicate the Pages environment | ||
| - `CF_PAGES_BRANCH` defaults to the current git branch (or `"local"` if not in a git repo) | ||
| - `CF_PAGES_COMMIT_SHA` defaults to the current git commit SHA (or a placeholder if not in a git repo) | ||
| - `CF_PAGES_URL` is set to a simulated commit preview URL (e.g., `https://<sha>.<project-name>.pages.dev`) | ||
|
|
||
| These variables are displayed with their actual values in the bindings table during startup, making it easy to verify what branch and commit SHA were detected. | ||
|
|
||
| These variables can be overridden by user-defined vars in the Wrangler configuration, `.env`, `.dev.vars`, or via CLI flags. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
petebacondarwin marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry quick review and I don't have time to dig too much into the details right now - also this is probably something to add the PR desc.
Why would
StartDevWorkerInputreceived defaults?Shoudn't the values be resolved by the caller instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good question. The problem is that if we merged them at the caller (say into the
vars) they would then take priority over the other possible sources such as the config file and the.envfile. These values are fallbacks for when they are not specified in any other case.