Middleware not protecting routes in version 2.5.0-11
Hi everyone, I was hoping to get some help with an issue i'm having with the middleware in my app.
For context, I updated my kinde-auth-nextjs version to 2.5.0-11 to try and take advantage of the new token refresh behavior. I needed to do this as I was working on a feature to update the user's username in both my database as well as their identity on Kinde.
The initial problem arose when I realized the updated username was not showing until the user logged out and logged back in. Therefore I looked into that issue and found a discussion post here: 💻┃supportrefresh token guide needed in which directed me to install version 2.5.0-11 in order to refresh the token seamlessly and receive my expected behavior of receiving the updated username in the new token.
In that PR https://github.com/kinde-oss/kinde-auth-nextjs/pull/254 it's discussed that the middleware essential becomes mandatory and to achieve this we'd need to update the matcher to run on every route
export const config = {
matcher: [
// Run on everything but Next internals and static files
'/((?!_next|[^?]\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).)',
],
}
As a side effect, my main problem arose & now my routes are not being protected and the user is not being redirected to the login page when the user requests a protected route. Would really appreciate help on this!
My sdk version is "@kinde-oss/kinde-auth-nextjs": "^2.5.0-11"
I've also attached images of what my middleware file currently looks like.
For context, I updated my kinde-auth-nextjs version to 2.5.0-11 to try and take advantage of the new token refresh behavior. I needed to do this as I was working on a feature to update the user's username in both my database as well as their identity on Kinde.
The initial problem arose when I realized the updated username was not showing until the user logged out and logged back in. Therefore I looked into that issue and found a discussion post here: 💻┃supportrefresh token guide needed in which directed me to install version 2.5.0-11 in order to refresh the token seamlessly and receive my expected behavior of receiving the updated username in the new token.
In that PR https://github.com/kinde-oss/kinde-auth-nextjs/pull/254 it's discussed that the middleware essential becomes mandatory and to achieve this we'd need to update the matcher to run on every route
export const config = {
matcher: [
// Run on everything but Next internals and static files
'/((?!_next|[^?]\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).)',
],
}
As a side effect, my main problem arose & now my routes are not being protected and the user is not being redirected to the login page when the user requests a protected route. Would really appreciate help on this!
My sdk version is "@kinde-oss/kinde-auth-nextjs": "^2.5.0-11"
I've also attached images of what my middleware file currently looks like.

GitHub
Explain your changes
This PR includes a significant improvement to token refreshing. Tokens now refresh seamlessly behind-the-scenes, providing users with the best possible experience.
In order to ...
This PR includes a significant improvement to token refreshing. Tokens now refresh seamlessly behind-the-scenes, providing users with the best possible experience.
In order to ...