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:
2026-04-07 10:40:59 +05:00
parent 8d3ff24e52
commit 024cf7adac
2 changed files with 3 additions and 14 deletions
+1 -1
View File
@@ -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;
+2 -13
View File
@@ -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") ||