scaffold: Next.js 15 + Drizzle + Better Auth + OpenAI + Recharts base

This commit is contained in:
Christopher Mayor
2026-04-24 14:29:47 -07:00
parent 858f7264ce
commit d13780931e
45 changed files with 9036 additions and 121 deletions

36
src/middleware.ts Normal file
View File

@@ -0,0 +1,36 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/lib/auth";
const publicPaths = ["/sign-in", "/sign-up", "/api/auth"];
export async function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
const isPublic = publicPaths.some(
(path) => pathname === path || pathname.startsWith(path + "/"),
);
if (isPublic) {
return NextResponse.next();
}
if (pathname.startsWith("/_next") || pathname.startsWith("/favicon")) {
return NextResponse.next();
}
const session = await auth.api.getSession({
headers: request.headers,
});
if (!session) {
const signInUrl = new URL("/sign-in", request.url);
signInUrl.searchParams.set("callbackUrl", pathname);
return NextResponse.redirect(signInUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};