Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Aug 11, 2025

Fixes #10215

This PR adds a new --domain flag to the wrangler deploy command that allows users to deploy directly to custom domains without manually configuring routes in their wrangler.toml file.

Changes

Core Implementation:

  • Added domains flag (with domain alias) to the deploy command definition
  • Domain strings are automatically converted to custom domain route objects ({ pattern: domain, custom_domain: true })
  • Domains are merged with existing configured routes and processed through the same validation and deployment pipeline
  • Updated triggersDeploy function's Props type to accept Route[] instead of string[] for routes

User Experience:

# Deploy to a single custom domain
wrangler deploy --domain api.example.com

# Deploy to multiple custom domains  
wrangler deploy --domain api.example.com --domain app.example.com

# Combine with existing route configuration
wrangler deploy --domain api.example.com  # works alongside routes in wrangler.toml

Testing:

  • Comprehensive test coverage for single/multiple domain deployment
  • Tests for combining domain flags with existing route configuration
  • Tests for domain validation (rejecting wildcards and paths)
  • Integration with existing custom domain deployment mocks

Key Implementation Details

The --domain flag leverages the existing custom domain infrastructure by converting domain strings to the same route format that custom domains already use internally. This ensures consistency with existing validation, deployment, and error handling.

Type System Change: Updated triggersDeploy Props to accept Route[] instead of string[] for routes to support the mixed route types (string routes and custom domain route objects).

Review Focus Areas

  1. Type System Impact: The change from string[] to Route[] in triggersDeploy Props - verify this doesn't break other callers
  2. Domain Conversion Logic: Ensure domains are correctly converted to { pattern: domain, custom_domain: true } format
  3. Route Merging: Verify that combining configured routes with domain routes works correctly
  4. Test Coverage: Review test mocks for accuracy and completeness
  5. Validation: Confirm that domain validation properly rejects invalid domains (wildcards, paths, etc.)

Link to Devin run: https://app.devin.ai/sessions/3f13f8ef54434b64accdb268e89f3aa1
Requested by: @petebacondarwin

  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: This is a new feature, not a bug fix

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: c75252b

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

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Major
@cloudflare/vitest-pool-workers 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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 11, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10312

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10312

miniflare

npm i https://pkg.pr.new/miniflare@10312

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10312

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10312

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10312

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10312

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10312

wrangler

npm i https://pkg.pr.new/wrangler@10312

commit: c75252b

@devin-ai-integration devin-ai-integration bot marked this pull request as ready for review August 11, 2025 10:59
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner August 11, 2025 10:59
petebacondarwin added a commit to cloudflare/cloudflare-docs that referenced this pull request Aug 11, 2025
@petebacondarwin petebacondarwin added the skip-v3-pr Skip validation of presence of a v3 backport PR label Aug 11, 2025
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Aug 11, 2025
- Add --domain flag (alias: --domains) to wrangler deploy command
- Convert domain strings to custom domain route format automatically
- Add comprehensive tests for domain flag functionality
- Validate domains using existing custom domain validation rules

Fixes #10215

Co-Authored-By: [email protected] <[email protected]>
@petebacondarwin petebacondarwin force-pushed the devin/1754905950-add-domain-flag branch from df254b2 to c7f34c7 Compare August 11, 2025 12:04
@devin-ai-integration
Copy link
Contributor Author

Thanks for the question! You're absolutely right to question this behavior. I investigated how --route flags currently work and found:

Current --route behavior:

  • CLI routes override config routes (using props.routes ?? config.routes)
  • They don't combine with existing routes - CLI routes completely replace config routes

Current --domain behavior:

  • Domains are added to whatever route source is active
  • If CLI routes are provided, domains work alongside CLI routes
  • If no CLI routes, domains work alongside config routes

This is actually consistent behavior. The test case name was misleading, so I updated it to "should deploy --domain flags alongside routes (from config when no CLI routes)" to clarify that domains work with the active route source.

The key insight is that domains are a different type of route (custom domain routes) that complement regular routes, rather than replacing them. This allows users to deploy to both regular routes and custom domains in a single command.

The behavior is working as intended - domains add custom domain routes to whatever route configuration is active (CLI routes if provided, otherwise config routes).

@petebacondarwin petebacondarwin merged commit bd8223d into main Aug 11, 2025
38 of 39 checks passed
@petebacondarwin petebacondarwin deleted the devin/1754905950-add-domain-flag branch August 11, 2025 20:03
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Aug 11, 2025
@workers-devprod workers-devprod added the contribution [Holopin] Recognizes an open-source contribution, big or small label Aug 11, 2025
@holopin-bot
Copy link

holopin-bot bot commented Aug 11, 2025

Congratulations @devin-ai-integration[bot], the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cme7jjh3j101707iej9txcbk0

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved!

@devin-ai-integration
Copy link
Contributor Author

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution [Holopin] Recognizes an open-source contribution, big or small skip-v3-pr Skip validation of presence of a v3 backport PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

accept --domain as a flag when deploying

3 participants