forked from alveoli-app/gitmesh.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
29 lines (26 loc) · 898 Bytes
/
middleware.ts
File metadata and controls
29 lines (26 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { withAuth } from 'next-auth/middleware'
import { NextResponse } from 'next/server'
export default withAuth(
function middleware(req) {
// For now, disable maintenance mode check to avoid Edge Runtime issues
// You can implement this via environment variables or API routes instead
const isMaintenancePage = req.nextUrl.pathname === '/maintenance'
const isApiRoute = req.nextUrl.pathname.startsWith('/api')
const isAdminRoute = req.nextUrl.pathname.startsWith('/admin')
// Add any additional middleware logic here
},
{
callbacks: {
authorized: ({ token, req }) => {
// Protect admin routes
if (req.nextUrl.pathname.startsWith('/admin')) {
return !!token && token.role === 'admin'
}
return true
},
},
}
)
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)']
}