-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.ts
30 lines (25 loc) · 925 Bytes
/
middleware.ts
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
30
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico).*)',
// '/flows/:path*',
'/navigator/asanaPostures/createAsana/:path*',
// '/navigator/asanaPostures/:path*',
// '/api/:path*', // API routes
],
}
export default function middleware(request: NextRequest) {
console.log('Middleware url:', request.url)
console.log('Middleware request:', request)
// Access session data
// const session = request.cookies.get('authjs.session-token') // the session cookie name
// console.log('Middleware session-token:', session)
if (process.env.NODE_ENV !== 'production') {
return NextResponse.next()
}
if (!request.nextUrl.pathname.startsWith('/protected')) {
return NextResponse.next()
}
return NextResponse.redirect(new URL('/auth/signin', request.url), 401)
}