Skip to content

Instantly share code, notes, and snippets.

@luscas
Created August 14, 2023 13:50
Show Gist options
  • Save luscas/70521c8348d82670aabf16d8d621f3fd to your computer and use it in GitHub Desktop.
Save luscas/70521c8348d82670aabf16d8d621f3fd to your computer and use it in GitHub Desktop.
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