Next.js proxy 307

Getting a 307 when trying to check session on Next.js new proxy

import { NextRequest, NextResponse } from "next/server"; import { headers } from "next/headers"; import { auth } from "@/lib/auth"; export async function proxy(request: NextRequest) { const session = await auth.api.getSession({ headers: await headers() }) // THIS IS NOT SECURE! // This is the recommended approach to optimistically redirect users // We recommend handling auth checks in each page/route if(!session) { return NextResponse.redirect(new URL("/sign-in", request.url)); } return NextResponse.next(); } export const config = { runtime: "nodejs", // Required for auth.api calls matcher: ["/dashboard"], // Specify the routes the middleware applies to };

session comes as null
Was this page helpful?