KindeK
Kinde2y ago
4 replies
Dave Gray

isReturnToCurrentPage in Next.js middleware

"@kinde-oss/kinde-auth-nextjs": "^2.3.3",
and
"next": "^14.2.3",

My middleware setting:
export default function middleware(req: NextRequest) {
  return withAuth(req, {
    isReturnToCurrentPage: true,
  });
}

My expectations:
- Go directly to domain.com/books/scifi and get redirected to login - as expected.
- After logging in, get redirected back to domain.com/books/scifi - fails.

I can see the GET request go through with this URL:
/api/auth/login?post_login_redirect_url=/books/scifi

But Next.js gives this error:
⨯ Error: URL is malformed "/books/scifi". Please use only absolute URLs
Was this page helpful?