Skip to content

Commit

Permalink
fix(client): add additional type (#4402)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
kafelix496 and ubbe-xyz committed Apr 22, 2022
1 parent 39b4d62 commit 9f40cd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/next-auth/src/jwt/index.ts
Expand Up @@ -2,7 +2,8 @@ import { EncryptJWT, jwtDecrypt } from "jose"
import hkdf from "@panva/hkdf"
import { v4 as uuid } from "uuid"
import { SessionStore } from "../core/lib/cookie"
import type { NextApiRequest } from "next"
import { NextRequest } from "next/server"
import type { NextApiRequest} from "next"
import type { JWT, JWTDecodeParams, JWTEncodeParams, JWTOptions } from "./types"
import type { LoggerInstance } from ".."

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

export interface GetTokenParams<R extends boolean = false> {
/** The request containing the JWT either in the cookies or in the `Authorization` header. */
req: NextApiRequest | Pick<NextApiRequest, "cookies" | "headers">
req: NextRequest | NextApiRequest | Pick<NextApiRequest, "cookies" | "headers">
/**
* Use secure prefix for cookie name, unless URL in `NEXTAUTH_URL` is http://
* or not set (e.g. development or test instance) case use unprefixed name
Expand Down
2 changes: 1 addition & 1 deletion packages/next-auth/src/next/middleware.ts
Expand Up @@ -81,7 +81,7 @@ async function handleMiddleware(
return NextResponse.redirect(errorUrl)
}

const token = await getToken({ req: req as any })
const token = await getToken({ req })

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

0 comments on commit 9f40cd1

Please sign in to comment.