fix: split middleware in two, authed and public

This commit is contained in:
Simon Emanuelsson
2024-03-27 09:33:31 +01:00
parent 445e523c9a
commit 7d83b1feb4
3 changed files with 82 additions and 57 deletions
+9
View File
@@ -1,4 +1,5 @@
import "next-auth"
import type { NextRequest } from "next/server"
// Module augmentation
// https://authjs.dev/getting-started/typescript#popular-interfaces-to-augment
@@ -21,6 +22,14 @@ declare module "next-auth" {
* Returned by `useSession`, `auth`, contains information about the active session.
*/
interface Session {}
/**
* NextAuthRequest isn't exported by next-auth so we declare a copy
* of how they do it to support or switch in middleware.ts
*/
interface NextAuthRequest extends NextRequest {
auth: Session | null
}
}
declare module "next-auth/jwt" {