t3dotgg / t3gallery

https://t3gallery.vercel.app
195 stars 31 forks source link

Clerk gives error but still allows auth to work #4

Open GiraffeCoding opened 2 months ago

GiraffeCoding commented 2 months ago

I've added the middleware.ts file into the src folder as taken from the blog article:

// middleware.ts
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";

const isProtectedRoute = createRouteMatcher(["/dashboard(.*)"]);

export default clerkMiddleware((auth, request) => {
  if (isProtectedRoute(request)) auth().protect();
});

export const config = {
  matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"],
};

The auth seems to work as I'm able to sign in and out with routes also being protected, but I'm getting the following error in the console:

image

Has anyone else had this error?

MartiinWalsh commented 2 months ago

Hey, what version of @clerk/nextjs are you using?

GiraffeCoding commented 2 months ago

It installed: 5.0.0-beta.45

MartiinWalsh commented 2 months ago

Not sure if it is related to your issue but 5.0.0-beta.38 was being used in the tutorial. However, Core 2 is now generally available so you can install "@clerk/nextjs": "^5.0.1"