Fix build errors for Next.js 16 + Prisma 7
- Fix Prisma import: use @/generated/prisma alias (resolves Turbopack issue) - Replace middleware.ts with proxy.ts (Next.js 16 convention) - middleware function renamed to proxy Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { PrismaClient } from "../generated/prisma";
|
import { PrismaClient } from "@/generated/prisma";
|
||||||
|
|
||||||
const globalForPrisma = globalThis as unknown as {
|
const globalForPrisma = globalThis as unknown as {
|
||||||
prisma: PrismaClient | undefined;
|
prisma: PrismaClient | undefined;
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getSessionCookie } from "better-auth/cookies";
|
import { getSessionCookie } from "better-auth/cookies";
|
||||||
|
|
||||||
const PUBLIC_ROUTES = [
|
const PUBLIC_ROUTES = ["/login", "/register", "/verify-email", "/api/auth"];
|
||||||
"/login",
|
|
||||||
"/register",
|
|
||||||
"/verify-email",
|
|
||||||
"/api/auth",
|
|
||||||
];
|
|
||||||
|
|
||||||
const ROLE_ROUTES: Record<string, string[]> = {
|
export function proxy(request: NextRequest) {
|
||||||
admin: ["/admin"],
|
|
||||||
curator: ["/curator", "/admin"],
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
|
||||||
const { pathname } = request.nextUrl;
|
const { pathname } = request.nextUrl;
|
||||||
|
|
||||||
// Allow public routes and static assets
|
|
||||||
if (
|
if (
|
||||||
PUBLIC_ROUTES.some((route) => pathname.startsWith(route)) ||
|
PUBLIC_ROUTES.some((route) => pathname.startsWith(route)) ||
|
||||||
pathname.startsWith("/_next") ||
|
pathname.startsWith("/_next") ||
|
||||||
Reference in New Issue
Block a user