fix: use named export for proxy.ts per Next.js 16 convention
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server"
|
import { NextResponse } from "next/server"
|
||||||
|
import type { NextRequest } from "next/server"
|
||||||
|
|
||||||
const authRoutes = [
|
const authRoutes = [
|
||||||
"/login",
|
"/login",
|
||||||
@@ -7,14 +8,18 @@ const authRoutes = [
|
|||||||
"/reset-password",
|
"/reset-password",
|
||||||
]
|
]
|
||||||
|
|
||||||
export default async function proxy(req: NextRequest) {
|
export function proxy(req: NextRequest) {
|
||||||
const path = req.nextUrl.pathname
|
const path = req.nextUrl.pathname
|
||||||
const isAuthRoute = authRoutes.some((route) => path.startsWith(route))
|
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
|
const hasSession = req.cookies
|
||||||
.getAll()
|
.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
|
// Redirect authenticated users away from auth pages
|
||||||
if (isAuthRoute && hasSession) {
|
if (isAuthRoute && hasSession) {
|
||||||
|
|||||||
Reference in New Issue
Block a user