JMAC
JMAC
KKinde
Created by JMAC on 3/13/2025 in #💻┃support
Kinde Auth Middleware Issue Report
Environment & Versions - Next.js version: 15.2.2 - React version: 19.0.0 - @kinde-oss/kinde-auth-nextjs version: 2.5.3 - File extension: middleware.js (not typescript) Issue Description The isReturnToCurrentPage parameter in the Kinde auth middleware is not working as expected. When included in the configuration, authentication stops working. If removed, everything works normally. Current Middleware Implementation import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware" export default function middleware(req) { return withAuth(req, { publicPaths: ["/"], isReturnToCurrentPage: true, }) } export const config = { matcher: [ "/((?!_next|[^?]\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).)", ], } Callback URLs Configuration The following callback URLs are configured in the Kinde dashboard: http://localhost:3000/api/auth/kinde_callback http://localhost:3000/home http://localhost:3000/tickets Troubleshooting Steps Taken Confirmed using the latest package version (2.5.3) Tried simplifying the middleware configuration and matcher pattern Verified that removing isReturnToCurrentPage: true resolves the issue Confirmed callback URLs are correctly set in the Kinde dashboard Expected Behavior When using isReturnToCurrentPage: true, users should be redirected back to the page they were trying to access after successful authentication. Actual Behavior When isReturnToCurrentPage: true is included in the configuration, the authentication flow breaks. Removing this parameter makes authentication work correctly, but users are not redirected back to their original page.
6 replies