The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Revert "make the RESEND_API_KEY optional"
Kiran K8e10fa1ecf34
diff --git a/apps/web/emails/index.ts b/apps/web/emails/index.tsindex d7a90acd88..adacaa3413 100644--- a/apps/web/emails/index.ts+++ b/apps/web/emails/index.ts@@ -18,14 +18,21 @@ export const sendEmail = async ({marketing?: boolean;}) => {if (process.env.NODE_ENV === "development" && !resend) {+ // Set up a fake email client for developmentconsole.info(- "RESEND_API_KEY is not set in the .env. Skipping sending email.",+ `Email to ${email} with subject ${subject} sent from ${+ from || process.env.NEXT_PUBLIC_APP_NAME+ }`,+ );+ return Promise.resolve();+ } else if (!resend) {+ console.error(+ "Resend is not configured. You need to add a RESEND_API_KEY in your .env file for emails to work.",);-return Promise.resolve();}- return resend?.emails.send({+ return resend.emails.send({to: email,from:from ||diff --git a/apps/web/lib/resend.ts b/apps/web/lib/resend.tsindex b465b4d44b..9b3a27956a 100644--- a/apps/web/lib/resend.ts+++ b/apps/web/lib/resend.ts@@ -1,8 +1,6 @@import { Resend } from "resend";-const resendApiKey = process.env.RESEND_API_KEY;--export const resend = resendApiKey ? new Resend(resendApiKey) : null;+export const resend = new Resend(process.env.RESEND_API_KEY);export async function subscribe({email,@@ -11,14 +9,12 @@ export async function subscribe({email: string;name?: string | null;}) {- const audienceId = process.env.RESEND_AUDIENCE_ID;-- if (!audienceId) {- console.error("RESEND_AUDIENCE_ID is not set in the .env. Skipping.");+ if (!process.env.RESEND_API_KEY || !process.env.RESEND_AUDIENCE_ID) {+ console.error("Resend API key or audience ID not found");return;}- return await resend?.contacts.create({+ return await resend.contacts.create({email,...(name && {firstName: name.split(" ")[0],@@ -29,7 +25,7 @@ export async function subscribe({}export async function unsubscribe({ email }: { email: string }) {- return await resend?.contacts.remove({+ return await resend.contacts.remove({email,audienceId: process.env.RESEND_AUDIENCE_ID as string,});diff --git a/apps/web/ui/analytics/feedback/action.ts b/apps/web/ui/analytics/feedback/action.tsindex 9f3056d0b5..96fc610d33 100644--- a/apps/web/ui/analytics/feedback/action.ts+++ b/apps/web/ui/analytics/feedback/action.ts@@ -7,7 +7,7 @@ export async function submitFeedback(data: FormData) {const email = data.get("email") as string;const feedback = data.get("feedback") as string;- return await resend?.emails.send({+ return await resend.emails.send({from: "[email protected]",to: "[email protected]",...(email && { replyTo: email }),