Next.js 15 + Kinde Auth – Protected routes not working after logout
Hey, I’m new to Next.js and I’m having the following issue:
I integrated Kinde login into my app, and login itself works fine. Afterwards, I want my routes to be protected – meaning that after logout I shouldn’t be able to access my pages/routes anymore unless I’m logged in.
The problem:
Even after logging out, I can still access my other pages – which should not be possible.
I followed a tutorial where the solution was to create a middleware.js in the lib folder with the following code:
I integrated Kinde login into my app, and login itself works fine. Afterwards, I want my routes to be protected – meaning that after logout I shouldn’t be able to access my pages/routes anymore unless I’m logged in.
The problem:
Even after logging out, I can still access my other pages – which should not be possible.
I followed a tutorial where the solution was to create a middleware.js in the lib folder with the following code: