Skip to content

Add optional RESEND_BASE_URL component env var - #168

Merged
convexwill merged 4 commits into
will/api-223-component-env-varsfrom
will/api-89-resend-support-baseurl
Dec 4, 2026
Merged

convexwill merged 4 commits into
will/api-223-component-env-varsfrom
will/api-89-resend-support-baseurl

Conversation

@convexwill

@convexwill convexwill commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #165 (review that first). API-89.

Adds an optional RESEND_BASE_URL component env var so batches can go to a Resend-compatible API, such as a local emulator in e2e tests. Unset means https://api.resend.com.

const app = defineApp({
  env: {
    RESEND_API_KEY: v.string(),
    RESEND_BASE_URL: v.optional(v.string()),
  },
});
app.use(resend, {
  env: {
    RESEND_API_KEY: app.env.RESEND_API_KEY,
    RESEND_BASE_URL: app.env.RESEND_BASE_URL,
  },
});

Based on #130 by @heracek, but it uses component env instead of a baseUrl client option, following #165. The component only sees the var if the app binds it, so a stray env var can't redirect production mail. It has the same name the resend SDK reads, so one env var also redirects emails you send yourself with the SDK.

Tests cover the custom URL (with and without a trailing slash) and the default. I also checked it on a local deployment.

🤖 Generated with Claude Code

Lets the component send batches to a Resend-compatible API, such as a
local emulator in end-to-end tests, instead of https://api.resend.com.
Based on #130, which added a baseUrl client option; this reads it from
component env instead, so the app opts in by binding it in
convex.config.ts. Trailing slashes are stripped.

Co-authored-by: heracek <tomas.horacek@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/resend@168

commit: ac2cee3

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Will Stockwell and others added 3 commits December 4, 2026 13:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@convexwill
convexwill merged commit 16cf1b6 into will/api-223-component-env-vars Dec 4, 2026
3 checks passed

@ianmacartney ianmacartney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few nits:

  • You could add this to the example convex.config to show how it works
  • The PR description was a bit Claude-ey and verbose. Ideally the bar is higher: "what is worth the reviewer's time to read"

@convexwill

Copy link
Copy Markdown
Contributor Author

This merged into the old #165 branch rather than main, so it never shipped. Replaced by the PR linked above.

Copy link
Copy Markdown
Member

not sure where "above" here is?

Copy link
Copy Markdown
Contributor Author

Let's try this one more time. I created a new PR, more concise message. Resolved the merge into main problem.

#169

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