Skip to content

Commit 9f40cd1

Browse files
jiyeol-lee0ubbe
andauthoredApr 22, 2022
fix(client): add additional type (#4402)
* Add additional type * do not cast to 'any' anymore * add missing import * import NextRequest from next/server Co-authored-by: Lluis Agusti <hi@llu.lu>
1 parent 39b4d62 commit 9f40cd1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎packages/next-auth/src/jwt/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { EncryptJWT, jwtDecrypt } from "jose"
22
import hkdf from "@panva/hkdf"
33
import { v4 as uuid } from "uuid"
44
import { SessionStore } from "../core/lib/cookie"
5-
import type { NextApiRequest } from "next"
5+
import { NextRequest } from "next/server"
6+
import type { NextApiRequest} from "next"
67
import type { JWT, JWTDecodeParams, JWTEncodeParams, JWTOptions } from "./types"
78
import type { LoggerInstance } from ".."
89

@@ -37,7 +38,7 @@ export async function decode(params: JWTDecodeParams): Promise<JWT | null> {
3738

3839
export interface GetTokenParams<R extends boolean = false> {
3940
/** The request containing the JWT either in the cookies or in the `Authorization` header. */
40-
req: NextApiRequest | Pick<NextApiRequest, "cookies" | "headers">
41+
req: NextRequest | NextApiRequest | Pick<NextApiRequest, "cookies" | "headers">
4142
/**
4243
* Use secure prefix for cookie name, unless URL in `NEXTAUTH_URL` is http://
4344
* or not set (e.g. development or test instance) case use unprefixed name

‎packages/next-auth/src/next/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async function handleMiddleware(
8181
return NextResponse.redirect(errorUrl)
8282
}
8383

84-
const token = await getToken({ req: req as any })
84+
const token = await getToken({ req })
8585

8686
const isAuthorized =
8787
(await options?.callbacks?.authorized?.({ req, token })) ?? !!token

0 commit comments

Comments
 (0)
Please sign in to comment.