fix: middleware redirects

This commit is contained in:
2026-02-03 19:05:20 +00:00
parent eff3316480
commit 609b9da020

View File

@@ -4,6 +4,7 @@ import {
isAuthenticatedNextjs,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";
import { NextResponse } from "next/server";
const isSignInPage = createRouteMatcher(["/auth"]);
const isProtectedPage = createRouteMatcher([
@@ -19,7 +20,7 @@ export default convexAuthNextjsMiddleware(async (request) => {
if (isProtectedPage(request) && !(await isAuthenticatedNextjs())) {
const nextUrl = new URL("/auth", request.url);
nextUrl.searchParams.set("next", request.nextUrl.pathname + request.nextUrl.search);
return nextjsMiddlewareRedirect(request, nextUrl.toString());
return NextResponse.redirect(nextUrl);
}
});