import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'
const isPublicRoute = createRouteMatcher(['/sign-in(.*)', '/sign-up(.*)'])
const isProtectedRoute = createRouteMatcher(['/dashboard(.*)'])
export default clerkMiddleware((auth, req) => {
if (!isPublicRoute(req)) {
auth().protect()
}
if (isProtectedRoute(req)) auth().protect()
})
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
}
this is the middleware, before sign in i cant access any page. All the pages are protected except sign in and signup pages. After sign in the URL is{ http://localhost:3000/sign-in?redirect_url=http%3A%2F%2Flocalhost%3A3000%2F }
GET /sign-in?redirect_url=http%3A%2F%2Flocalhost%3A3000%2Ftest 200 in 88ms
GET /sign-in?redirect_url=http%3A%2F%2Flocalhost%3A3000%2Ftest 200 in 41ms
GET /sign-in/SignIn_clerk_catchall_check_1723370469288 200 in 46ms
After sign in this is the error i get in the terminal. i am being redirected to the above URL after sign in.
I cant access the dashboard or any other page. I am redirected to above URL.
how to change this.
I tried reading clerk docs, i tried chat-GPT i tried stack overflow. i tried every thing i can , but nothing changed.