Skip to content

Default Cloudflare email API base URL - #143

Merged
kentcdodds merged 1 commit into
mainfrom
cursor/cloudflare-email-default-api-base-url
Apr 9, 2026
Merged

kentcdodds merged 1 commit into
mainfrom
cursor/cloudflare-email-default-api-base-url

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Apr 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • default Cloudflare email sending to https://api.cloudflare.com when CLOUDFLARE_API_BASE_URL is unset
  • keep local/mock Cloudflare email behavior working when a custom mock base URL is provided
  • remove production deploy secret syncing that implied a custom Cloudflare API base URL was needed for email
  • update contributor docs to clarify that production email uses the public Cloudflare API base by default

Testing

  • npx vitest run packages/worker/src/app/email/cloudflare-email.node.test.ts tools/ci/sync-worker-secrets.node.test.ts
  • npm run test:e2e:install (required once in this environment so the push-gate Playwright browser existed)
  • npm run test:push
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • Email sending now works with a default Cloudflare API base URL when the configuration variable is not explicitly set.
  • Documentation

    • Clarified that Cloudflare API credentials support email sending, browser rendering, and worker functionality.
    • Updated configuration documentation to reflect default API base URL behavior.
  • Tests

    • Updated email tests to verify correct behavior when using default API configuration.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27cb406c-642f-4b04-b510-70721cf92adf

📥 Commits

Reviewing files that changed from the base of the PR and between 6310506 and a1cdb1e.

📒 Files selected for processing (7)
  • .github/workflows/deploy.yml
  • docs/contributing/environment-variables.md
  • docs/contributing/setup-manifest.md
  • packages/worker/.env.example
  • packages/worker/src/app/email/cloudflare-email.node.test.ts
  • packages/worker/src/app/email/cloudflare-email.ts
  • packages/worker/src/app/handlers/password-reset.ts

📝 Walkthrough

Walkthrough

The pull request refactors Cloudflare API base URL handling by removing the requirement for CLOUDFLARE_API_BASE_URL to be explicitly set. The email sending logic now defaults to the public Cloudflare API endpoint when the environment variable is unset, while the deployment workflow no longer passes this variable to the secrets synchronization step. Documentation and tests are updated to reflect this behavior.

Changes

Cohort / File(s) Summary
Workflow Configuration
.github/workflows/deploy.yml
Removed CLOUDFLARE_API_BASE_URL environment variable and corresponding --set-from-env-optional argument from the "Sync Cloudflare Secrets (bulk)" step.
Documentation
docs/contributing/environment-variables.md, docs/contributing/setup-manifest.md, packages/worker/.env.example
Updated explanatory text to clarify that Cloudflare API is used for both Browser Rendering and email sending, and documented default API base URL behavior when the environment variable is unset.
Email Service Logic
packages/worker/src/app/email/cloudflare-email.ts
Added defaultCloudflareApiBaseUrl constant and modified sendCloudflareEmail() to use it as fallback when config.apiBaseUrl is missing or empty. Simplified hasApiConfig() to no longer require API base URL presence.
Email Service Tests
packages/worker/src/app/email/cloudflare-email.node.test.ts
Replaced test asserting behavior when API config is missing with new test verifying use of default Cloudflare API base URL.
Handler Integration
packages/worker/src/app/handlers/password-reset.ts
Changed to pass CLOUDFLARE_API_BASE_URL environment variable directly without nullish-coalescing fallback.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hop, hop, the URLs now find their way,
With defaults in place, no config today!
Cloudflare's base stands when unset it be,
Email sends smoothly as defaults decree!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/cloudflare-email-default-api-base-url

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kentcdodds
kentcdodds marked this pull request as ready for review April 9, 2026 21:46
@kentcdodds
kentcdodds merged commit 04f88f2 into main Apr 9, 2026
14 of 16 checks passed
@kentcdodds
kentcdodds deleted the cursor/cloudflare-email-default-api-base-url branch April 17, 2026 00:59
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.

2 participants