From 067df2ba9243c50f5f48f4caa744b1da09ffb3bf Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sun, 26 Apr 2026 19:35:04 +0800 Subject: [PATCH] fix: use named export for proxy.ts per Next.js 16 convention --- proxy.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/proxy.ts b/proxy.ts index 4447b46..cb35657 100644 --- a/proxy.ts +++ b/proxy.ts @@ -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) {