Skip to content

Commit

Permalink
fix: getServerToken returns null when used in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Niki2k1 committed Dec 27, 2023
1 parent f59334d commit 5bfbe4f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/authjs-nuxt/src/runtime/lib/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { RuntimeConfig } from "nuxt/schema"
import { Auth, skipCSRFCheck } from "@auth/core"
import type { H3Event } from "h3"
import { eventHandler, getRequestHeaders, getRequestURL } from "h3"
import { eventHandler, getRequestHeaders, getRequestURL, parseCookies } from "h3"
import type { AuthConfig, Session } from "@auth/core/types"
import { getToken } from "@auth/core/jwt"
import { checkOrigin, getAuthJsSecret, getRequestFromEvent, getServerOrigin, makeCookiesFromCookieString } from "../utils"
Expand Down Expand Up @@ -65,11 +65,11 @@ export async function getServerSession(
*/
export async function getServerToken(event: H3Event, options: AuthConfig, runtimeConfig?: Partial<RuntimeConfig>) {
const response = await getServerSessionResponse(event, options)
const cookies = Object.fromEntries(response.headers.entries())
const parsedCookies = makeCookiesFromCookieString(cookies["set-cookie"])
const cookies = parseCookies(event)

const parameters = {
req: {
cookies: parsedCookies,
cookies,
headers: response.headers as unknown as Record<string, string>
},
// see https://github.com/nextauthjs/next-auth/blob/a79774f6e890b492ae30201f24b3f7024d0d7c9d/packages/core/src/jwt.ts
Expand Down

0 comments on commit 5bfbe4f

Please sign in to comment.