fix random auth errors

idk how i did it
This commit is contained in:
2025-08-16 22:15:22 -04:00
parent 1fe3ef0ee1
commit 1fdc20ee0c
2 changed files with 27 additions and 29 deletions

25
src/middleware.ts Normal file
View File

@@ -0,0 +1,25 @@
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)(.*)',
],
}