Convex + Better Auth Local Install Missing API Key (Resend)
After following local install in https://convex-better-auth.netlify.app/local-install, I've been having this error "Failed to analyze adapter.js: Uncaught Error: Missing API key. Pass it to the constructor
new Resend("re_123")
" during build time, I'm using the actual resend package for auth related emails since I can't use the resend component.
RESEND_API_KEY is already in my .env.local as well as in convex cloud envs, When passing the actual api as string it works, when passing env in the build command it works. Problem is I can't do that in prod.
Anyone having this issue?
Stack: Sveltekit, Convex, Better Auth, Resend3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
If you're calling
new Resend()
in your Better Auth component directory, it won't have access to env vars. This is a security feature of components - if you want them to have a value from env var, you have to pass the env var value as an arg from your app to the component.
You should be able to conduct all of your email sending through your Better Auth config, which does have env var access since it's not in a component directory.Thanks @erquhart, how do I pass an arg to a component though? Can you share me a link or a sample code I can follow. I can't find it in the convex docs or at least not yet.
@erquhart nevermind, your second comment solve my issue. Turns out I've been accessing env's in there all along.
For anyone who'll encounter this issue access your env's inside betterAuth config instead of making a helper somewhere else
e.g.