From 60c858dc89144400614e867928cbde4346ccfd24 Mon Sep 17 00:00:00 2001
From: g-but <41178744+g-but@users.noreply.github.com>
Date: Mon, 18 May 2026 15:44:09 +0200
Subject: [PATCH] fix(build): lazy-init Resend SDK to fix Vercel build crash;
centralize auth routes
Resend SDK throws at construction when given an empty string API key, which
crashed next build on routes that import email.ts. Fix: lazy-initialize via
getResend() so the Resend instance is only created at send time, not module
evaluation time.
Route SSOT: create src/config/auth.ts with ROUTES and PUBLIC_NAV_LINKS constants.
Replace 25+ hardcoded "/sign-in", "/today", "/onboarding" etc. strings across
all auth pages, public pages, AuthShell, SignInForm, and SidebarFooter. Nav
links for public surface (landing + auth) now come from one place.
Co-Authored-By: Claude Sonnet 4.6
---
src/app/forgot-password/page.tsx | 5 ++--
src/app/invite/[token]/page.tsx | 7 +++---
src/app/onboarding/page.tsx | 5 ++--
src/app/page.tsx | 21 ++++++----------
src/app/reset-password/[token]/page.tsx | 5 ++--
src/app/setup/page.tsx | 5 ++--
src/app/sign-up/page.tsx | 7 +++---
src/app/verify-email/page.tsx | 5 ++--
src/app/whitepaper/page.tsx | 5 ++--
src/components/auth/AuthShell.tsx | 11 +++-----
src/components/auth/SignInForm.tsx | 9 ++++---
.../shell/sidebar/SidebarFooter.tsx | 3 ++-
src/config/auth.ts | 25 +++++++++++++++++++
src/lib/email.ts | 12 ++++++---
14 files changed, 78 insertions(+), 47 deletions(-)
create mode 100644 src/config/auth.ts
diff --git a/src/app/forgot-password/page.tsx b/src/app/forgot-password/page.tsx
index ba571e6ad..00b43ea20 100644
--- a/src/app/forgot-password/page.tsx
+++ b/src/app/forgot-password/page.tsx
@@ -7,6 +7,7 @@ import {
AuthFooterLink, AuthHeading,
} from "@/components/auth/AuthShell";
import { postJson } from "@/lib/api/fetch";
+import { ROUTES } from "@/config/auth";
export default function ForgotPasswordPage() {
const [email, setEmail] = useState("");
@@ -35,7 +36,7 @@ export default function ForgotPasswordPage() {
title="Check your email"
description={`If an account exists for ${email}, we've sent a reset link. Check your inbox (and spam folder).`}
/>
- ← Back to sign in
+ ← Back to sign in
);
}
@@ -74,7 +75,7 @@ export default function ForgotPasswordPage() {
Remember it?{" "}
-
+
Sign in
diff --git a/src/app/invite/[token]/page.tsx b/src/app/invite/[token]/page.tsx
index 7e710befd..0a0b1fc6c 100644
--- a/src/app/invite/[token]/page.tsx
+++ b/src/app/invite/[token]/page.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import Link from "next/link";
import { signIn } from "next-auth/react";
import { getJson, postJson } from "@/lib/api/fetch";
+import { ROUTES } from "@/config/auth";
import {
AuthShell, AuthCard, AuthField, AuthInput, AuthSubmitButton, AuthIconBadge, AuthHeading,
} from "@/components/auth/AuthShell";
@@ -53,9 +54,9 @@ export default function InvitePage({ params }: { params: Promise<{ token: string
const result = await signIn("user-password", { userId: data.userId, password, redirect: false });
if (result?.ok) {
- router.push("/today");
+ router.push(ROUTES.APP_HOME);
} else {
- router.push("/sign-in");
+ router.push(ROUTES.SIGN_IN);
}
} catch {
setError("Something went wrong.");
@@ -88,7 +89,7 @@ export default function InvitePage({ params }: { params: Promise<{ token: string
{isError && (
- Sign in{" "}
+ Sign in{" "}
if you already have an account.
)}
diff --git a/src/app/onboarding/page.tsx b/src/app/onboarding/page.tsx
index 7dd77679a..9da587dc7 100644
--- a/src/app/onboarding/page.tsx
+++ b/src/app/onboarding/page.tsx
@@ -6,6 +6,7 @@ import { useSession } from "next-auth/react";
import { Loader2, GitBranch, Star, Lock } from "lucide-react";
import { normalizeUsername } from "@/lib/username";
import { postJson, patchJson, throwApiError } from "@/lib/api/fetch";
+import { ROUTES } from "@/config/auth";
import {
AuthShell,
AuthCard,
@@ -137,7 +138,7 @@ export default function OnboardingPage() {
if (orgsData.orgs && orgsData.orgs.length > 0) {
await patchJson("/api/me", { onboardedAt: new Date().toISOString() });
await update();
- router.push("/today");
+ router.push(ROUTES.APP_HOME);
return;
}
@@ -168,7 +169,7 @@ export default function OnboardingPage() {
}
await patchJson("/api/me", { onboardedAt: new Date().toISOString() });
await update();
- router.push("/today");
+ router.push(ROUTES.APP_HOME);
} catch (e) {
setError(e instanceof Error ? e.message : "Something went wrong");
} finally {
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 68bb594a4..adf54b7f6 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -12,30 +12,25 @@ import {
LANDING_WHITEPAPER_LABEL,
} from "@/config/marketing";
import { isStripeReady } from "@/lib/stripe";
-
-const NAV_LINKS = [
- { label: "Features", href: "#features" },
- { label: "Pricing", href: "#pricing" },
- { label: "Whitepaper", href: "/whitepaper" },
-];
+import { ROUTES, PUBLIC_NAV_LINKS } from "@/config/auth";
export default async function LandingPage() {
if ((await getUserCount()) === 0) redirect("/setup");
const session = await auth();
- if (session?.user) redirect("/today");
+ if (session?.user) redirect(ROUTES.APP_HOME);
const stripeReady = isStripeReady();
return (
-
+
Sign in
-
+
Get started →
@@ -55,7 +50,7 @@ export default async function LandingPage() {