Files
local-cal/src/middleware.ts
2025-08-16 22:15:22 -04:00

26 lines
727 B
TypeScript

import { auth } from "@/auth"
export default auth((req) => {
const { nextUrl } = req
const isLoggedIn = !!req.auth
// Protect dashboard routes
// if (nextUrl.pathname.startsWith('/api') && !isLoggedIn) {
// return Response.redirect(new URL('/signin', nextUrl))
// }
// Redirect logged-in users from sign-in page
if (nextUrl.pathname.startsWith('/signin') && isLoggedIn) {
return Response.redirect(new URL('/', nextUrl))
}
})
export const config = {
matcher: [
// Skip Next.js internals and all static files
'/((?!_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)(.*)',
],
}