Search code examples
next.jsclerk

Is there a reason why `middleware.ts` warning continues to persist even after removing Clerk


Recently just removed "Clerk" installation from my project, and made a push to production. But continue to get the error below, blocking my push to go live. Searching for any references to clerk in my app returns nothing, can you help figure out how to resolve this issue?

I am using NextJs version ^13.4.12;

Removed Clerk with this command to remove the package from my project: npm rm -rf @clerk/nextjs

INFO: Clerk: The request to /login is being redirected because there is no signed-in user, and the path is not included in `ignoredRoutes` or `publicRoutes`. To prevent this behavior, choose one of:

1. To make the route accessible to both signed in and signed out users, add "/login" to the `publicRoutes` array passed to authMiddleware
2. To prevent Clerk authentication from running at all, pass `ignoredRoutes: ["/((?!api|trpc))(_next|.+\..+)(.*)", "/login"]` to authMiddleware
3. Pass a custom `afterAuth` to authMiddleware, and replace Clerk's default behavior of redirecting unless a route is included in publicRoutes

For additional information about middleware, please visit https://clerk.com/docs/nextjs/middleware
(This log only appears in development mode, or if `debug: true` is passed to authMiddleware)

Solution

  • I was also using authMiddleware package from @clerk/nextjs in middleware.ts and I faced similar problems trying to have all the public routes.

    import { authMiddleware } from "@clerk/nextjs"; 
    
    const middlewareConfig = {
        publicRoutes: ['/'],
    };
    

    I had to use an empty default function to work, otherwise it was throwing in errors.

    export default authMiddleware({});