I'm using @convex-dev/auth (github oAuth) in my next js app,
I noticed that after sometime the token expires, however, the middleware is not kicking the user out, thus the page request is proceeding and getting error in response from the server.
following is the middleware code
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
isAuthenticatedNextjs
} from "@convex-dev/auth/nextjs/server";
const isPublicPage = createRouteMatcher(["/"]);
export default convexAuthNextjsMiddleware((request) => {
if (!isPublicPage(request) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, "/");
}
if (isPublicPage(request) && isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, "/modules");
}
});
export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};