Skip to content

Commit 6100784

Browse files
ericyangpanclaude
andcommitted
feat(deploy): enable Cloudflare Workers preview URLs with alias
- Add preview_urls = true to wrangler.toml - Update deploy-preview.yml to use versions upload --preview-alias - Implement new Cloudflare preview URL format with alias support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6498436 commit 6100784

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ jobs:
3838
CONTEXT_LABEL="Branch $RAW_BRANCH"
3939
fi
4040
41-
WORKER_NAME="aicodingstack-$CF_BRANCH"
42-
PREVIEW_URL="https://${WORKER_NAME}.pr-preview.workers.dev"
41+
# Cloudflare Preview URLs (aliased) format:
42+
# <ALIAS>-<WORKER_NAME>.<SUBDOMAIN>.workers.dev
43+
# See: https://developers.cloudflare.com/workers/configuration/previews/
44+
PREVIEW_ALIAS="$CF_BRANCH"
45+
WORKER_NAME="aicodingstack"
46+
PREVIEW_URL="https://${PREVIEW_ALIAS}-${WORKER_NAME}.pr-preview.workers.dev"
4347
4448
{
4549
echo "cf_branch=$CF_BRANCH"
4650
echo "worker_name=$WORKER_NAME"
51+
echo "preview_alias=$PREVIEW_ALIAS"
4752
echo "preview_url=$PREVIEW_URL"
4853
echo "context_label=$CONTEXT_LABEL"
4954
} >> "$GITHUB_OUTPUT"
@@ -70,7 +75,7 @@ jobs:
7075
with:
7176
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7277
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
73-
command: deploy --branch ${{ steps.preview_meta.outputs.cf_branch }}
78+
command: versions upload --preview-alias ${{ steps.preview_meta.outputs.preview_alias }}
7479

7580
- name: Comment Preview URL
7681
if: github.event_name == 'pull_request'

wrangler.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name = "aicodingstack"
22
main = ".open-next/worker.js"
33
compatibility_date = "2025-11-01"
4+
preview_urls = true
45
compatibility_flags = [
56
"nodejs_compat",
67
"global_fetch_strictly_public",

0 commit comments

Comments
 (0)