Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Resend not required for local dev

Richie McIlroy5454b9311d13
diff --git a/apps/web/app/login/form.tsx b/apps/web/app/login/form.tsx
index c78c551ac..69f43e377 100644
--- a/apps/web/app/login/form.tsx
+++ b/apps/web/app/login/form.tsx
@@ -65,6 +65,14 @@ export function LoginForm() {
}}
className="block w-full appearance-none rounded-full border border-gray-300 px-3 h-12 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black text-lg"
/>
+ {process.env.NODE_ENV === "development" && (
+ <div className="py-3 px-6 flex items-center justify-center bg-red-600 rounded-xl mt-3">
+ <p className="text-white text-lg">
+ <span className="font-bold text-white">Development mode:</span>{" "}
+ Auth URL will be logged to console
+ </p>
+ </div>
+ )}
</div>
<Button
variant="default"
diff --git a/packages/database/auth/auth-options.ts b/packages/database/auth/auth-options.ts
index 0de9a1956..a96fe21b8 100644
--- a/packages/database/auth/auth-options.ts
+++ b/packages/database/auth/auth-options.ts
@@ -24,11 +24,15 @@ export const authOptions: NextAuthOptions = {
providers: [
EmailProvider({
sendVerificationRequest({ identifier, url }) {
- sendEmail({
- email: identifier,
- subject: `Your Cap Login Link`,
- react: LoginLink({ url, email: identifier }),
- });
+ if (process.env.NODE_ENV === "development") {
+ console.log(`Login link: ${url}`);
+ } else {
+ sendEmail({
+ email: identifier,
+ subject: `Your Cap Login Link`,
+ react: LoginLink({ url, email: identifier }),
+ });
+ }
},
}),
],
diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.ts
index 95214f2b0..3fcf86446 100644
--- a/packages/database/emails/config.ts
+++ b/packages/database/emails/config.ts
@@ -1,7 +1,9 @@
import { JSXElementConstructor, ReactElement } from "react";
import { Resend } from "resend";
-export const resend = new Resend(process.env.RESEND_API_KEY);
+export const resend = process.env.RESEND_API_KEY
+ ? new Resend(process.env.RESEND_API_KEY)
+ : null;
export const sendEmail = async ({
email,
@@ -16,12 +18,11 @@ export const sendEmail = async ({
marketing?: boolean;
test?: boolean;
}) => {
- if (!process.env.RESEND_API_KEY) {
- console.log(
- "Resend is not configured. You need to add a RESEND_API_KEY in your .env file for emails to work."
- );
+ if (!resend) {
+ console.info(`Email to ${email} with subject ${subject} sent from Cap`);
return Promise.resolve();
}
+
return resend.emails.send({
from: marketing
? "Richie from Cap.so <[email protected]>"