Created
December 28, 2021 15:34
-
-
Save skolhustick/2360b353db69d8824885a2506b79014c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getToken } from 'next-auth/jwt' | |
| import { NextResponse } from 'next/server' | |
| export async function middleware (req) { | |
| const session = await getToken({ | |
| req, | |
| secret: process.env.SECRET, | |
| secureCookie: process.env.NEXTAUTH_URL?.startsWith('https://') | |
| }) | |
| if (!session) return NextResponse.redirect('/api/auth/signin') | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment