update Clerk V5

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-04-24 18:26:53 +02:00
parent 288fd6f6d0
commit e2d56fb34f
15 changed files with 360 additions and 330 deletions

View File

@@ -1,12 +1,25 @@
import { authMiddleware } from '@clerk/nextjs';
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
// This example protects all routes including api/trpc routes
// Please edit this to allow other routes to be public as needed.
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your Middleware
export default authMiddleware({
publicRoutes: ['/share/overview/:id', '/api/trpc(.*)', '/api/clerk/(.*)?'],
debug: process.env.CLERK_DEBUG ? true : false,
});
const isPublicRoute = createRouteMatcher([
'/share/overview/:id',
'/api/clerk/(.*)?',
'/login',
'/register',
]);
export default clerkMiddleware(
(auth, req) => {
if (!isPublicRoute(req)) {
auth().protect();
}
},
{
debug: !!process.env.CLERK_DEBUG,
}
);
export const config = {
matcher: [