fix: use named export for proxy.ts per Next.js 16 convention

This commit is contained in:
2026-04-26 19:35:04 +08:00
parent b2ce6f966b
commit 067df2ba92
+9 -4
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server"
import { NextResponse } from "next/server"
import type { NextRequest } from "next/server"
const authRoutes = [
"/login",
@@ -7,14 +8,18 @@ const authRoutes = [
"/reset-password",
]
export default async function proxy(req: NextRequest) {
export function proxy(req: NextRequest) {
const path = req.nextUrl.pathname
const isAuthRoute = authRoutes.some((route) => path.startsWith(route))
// Check for better-auth session cookie
// Check for better-auth session cookie (default name: better-auth.session_token)
const hasSession = req.cookies
.getAll()
.some((cookie) => cookie.name.startsWith("better-auth."))
.some(
(cookie) =>
cookie.name.startsWith("better-auth.") &&
cookie.value.length > 0,
)
// Redirect authenticated users away from auth pages
if (isAuthRoute && hasSession) {