Created
August 14, 2023 13:50
-
-
Save luscas/70521c8348d82670aabf16d8d621f3fd to your computer and use it in GitHub Desktop.
This file contains 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 { withAuth } from "next-auth/middleware"; | |
export default withAuth({ | |
callbacks: { | |
authorized: ({ token }) => { | |
if (token) { | |
const expiration = Number(token.exp) * 1000; | |
const now = Date.now(); | |
if (expiration < now) { | |
return false; | |
} | |
return true; | |
} | |
return false; | |
}, | |
}, | |
}); | |
export const config = { | |
matcher: [ | |
// ... | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment