feat(web): support custom domain#747
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds optional Cloudflare custom domain support for the web Worker. A new ChangesCloudflare Custom Domain for Web Worker
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@terraform/environments/production/locals.tf`:
- Around line 13-18: The web_custom_domain_enabled local variable currently only
checks var.web_platform, var.cloudflare_custom_domain for null and empty values,
but does not validate that var.cloudflare_zone_id is also provided. This allows
the condition to evaluate true even when cloudflare_zone_id is null, causing the
cloudflare_workers_custom_domain.web_app resource creation to fail at apply
time. Update the condition for web_custom_domain_enabled to include additional
checks ensuring var.cloudflare_zone_id is not null and not an empty string,
alongside the existing platform and custom domain validations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 72f907d6-97f6-4219-b000-0ffe8dd650b3
📒 Files selected for processing (4)
terraform/environments/production/locals.tfterraform/environments/production/terraform.tfvars.exampleterraform/environments/production/variables.tfterraform/environments/production/web-cloudflare.tf
1b34555 to
594be19
Compare
|
@ColeMurray ready for review - I've been able to use this successfully. |
|
I will note there is a similar PR in #604 but it doesn't include code to configure the domain in terraform with |
ColeMurray
left a comment
There was a problem hiding this comment.
[Automated Review] — Thermo-nuclear code quality pass
Functionally sound and correctly placed: web_app_url is the right single source of truth (it propagates to NEXTAUTH_URL, the slack/linear/control-plane WEB_APP_URL vars, outputs.tf, and the Vercel path), and the resource is schema-valid for the pinned provider — I verified cloudflare_workers_custom_domain against v5.19 (hostname+service required; account_id/zone_id optional; environment deprecated), so dropping environment is correct.
Inline findings, by priority:
- [locals.tf] The
web_app_urlchange grows a 3-way nested ternary that conflates platform-choice with host-choice — reframe via aweb_cloudflare_hostlocal so it stays binary. (primary) - [web-cloudflare.tf]
servicere-hardcodes the worker name a 4th time; extractlocal.web_worker_nameto make the invariant explicit. - [locals.tf] The
web_custom_domain_enabledflag is a long line duplicating a null-check pattern; match the file's existingtrimspace(...)idiom. - [variables.tf] Optional: guard the silent fallback when
cloudflare_custom_domainis set withoutcloudflare_zone_id, reusing the existingchecks.tfpattern.
None are correctness blockers. I'd ask for 1 + 2 before merge; 3 and 4 are strongly recommended.
594be19 to
bb03ce2
Compare
Support a custom domain for the Cloudflare web Worker
Adds the ability to serve the web app on a custom domain (e.g.
app.example.com)instead of the default
*.workers.devURL whenweb_platform = "cloudflare".There was an existing
cloudflare_zone_idterraform variable, but it was unused.Changes
variables.tf— new optionalcloudflare_custom_domainvariable (the hostname to attach), alongside the existingcloudflare_zone_id. Defaults tonull.web-cloudflare.tf— newcloudflare_workers_custom_domain.web_appresource that attaches the hostname to the web Worker. Cloudflare provisions the DNS record and edge certificate. Gated onlocal.web_custom_domain_enabledand depends on the Worker deploy.locals.tf— addedweb_custom_domain_enabledflag and a third case toweb_app_url. When a custom domain is set, the app URL (used forNEXTAUTH_URLand cross-service config) becomeshttps://<custom-domain>instead of theworkers.devURL.terraform.tfvars.example— documented the newcloudflare_custom_domaininput under the Cloudflare zone section.Behavior
The custom domain only activates when all of the following are true:
web_platform = "cloudflare"cloudflare_zone_idis setcloudflare_custom_domainis non-emptyOtherwise the deployment falls back to the existing
workers.devURL — no change for existing deployments.Notes
cloudflare_zone_id).terraform validatepasses cleanly (dropped the deprecatedenvironmentattribute on the resource).Summary by CodeRabbit