Created
September 18, 2023 20:49
-
-
Save mauriciord/9af1ebd21aa066c9dd73860a90996efa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/next-auth/next/index.js b/node_modules/next-auth/next/index.js | |
index b17feef..3e56332 100644 | |
--- a/node_modules/next-auth/next/index.js | |
+++ b/node_modules/next-auth/next/index.js | |
@@ -58,11 +58,6 @@ async function NextAuthRouteHandler(req, context, options) { | |
(_options$secret2 = options.secret) !== null && _options$secret2 !== void 0 ? _options$secret2 : options.secret = process.env.NEXTAUTH_SECRET; | |
- const { | |
- headers, | |
- cookies | |
- } = require("next/headers"); | |
- | |
const nextauth = (_context$params = context.params) === null || _context$params === void 0 ? void 0 : _context$params.nextauth; | |
const query = Object.fromEntries(req.nextUrl.searchParams); | |
const body = await (0, _utils.getBody)(req); | |
@@ -70,8 +65,8 @@ async function NextAuthRouteHandler(req, context, options) { | |
req: { | |
body, | |
query, | |
- cookies: Object.fromEntries(cookies().getAll().map(c => [c.name, c.value])), | |
- headers: Object.fromEntries(headers()), | |
+ cookies: Object.fromEntries(Array.from(req.cookies.entries()).map(([name, value]) => [name, value])), | |
+ headers: req.headers, | |
method: req.method, | |
action: nextauth === null || nextauth === void 0 ? void 0 : nextauth[0], | |
providerId: nextauth === null || nextauth === void 0 ? void 0 : nextauth[1], | |
@@ -124,35 +119,11 @@ async function getServerSession(...args) { | |
const isRSC = args.length === 0 || args.length === 1; | |
let req, res, options; | |
- if (isRSC) { | |
- options = Object.assign({}, args[0], { | |
- providers: [] | |
- }); | |
- | |
- const { | |
- headers, | |
- cookies | |
- } = require("next/headers"); | |
- | |
- req = { | |
- headers: Object.fromEntries(headers()), | |
- cookies: Object.fromEntries(cookies().getAll().map(c => [c.name, c.value])) | |
- }; | |
- res = { | |
- getHeader() {}, | |
- | |
- setCookie() {}, | |
- | |
- setHeader() {} | |
- | |
- }; | |
- } else { | |
- req = args[0]; | |
- res = args[1]; | |
- options = Object.assign({}, args[2], { | |
- providers: [] | |
- }); | |
- } | |
+ req = args[0]; | |
+ res = args[1]; | |
+ options = Object.assign({}, args[2], { | |
+ providers: [] | |
+ }); | |
(_options$secret3 = (_options = options).secret) !== null && _options$secret3 !== void 0 ? _options$secret3 : _options.secret = process.env.NEXTAUTH_SECRET; | |
const session = await (0, _core.AuthHandler)({ | |
diff --git a/node_modules/next-auth/src/next/index.ts b/node_modules/next-auth/src/next/index.ts | |
index 79a76ca..e42eeef 100644 | |
--- a/node_modules/next-auth/src/next/index.ts | |
+++ b/node_modules/next-auth/src/next/index.ts | |
@@ -1,5 +1,5 @@ | |
import { AuthHandler } from "../core" | |
-import { setCookie, getBody, toResponse } from "./utils" | |
+import { getBody, setCookie, toResponse } from "./utils" | |
import type { | |
GetServerSidePropsContext, | |
@@ -9,8 +9,8 @@ import type { | |
import { type NextRequest } from "next/server" | |
import type { AuthOptions, Session } from ".." | |
import type { | |
- CallbacksOptions, | |
AuthAction, | |
+ CallbacksOptions, | |
NextAuthRequest, | |
NextAuthResponse, | |
} from "../core/types" | |
@@ -73,7 +73,6 @@ async function NextAuthRouteHandler( | |
options.secret ??= process.env.NEXTAUTH_SECRET | |
// eslint-disable-next-line @typescript-eslint/no-var-requires | |
- const { headers, cookies } = require("next/headers") | |
const nextauth = context.params?.nextauth | |
const query = Object.fromEntries(req.nextUrl.searchParams) | |
const body = await getBody(req) | |
@@ -82,11 +81,10 @@ async function NextAuthRouteHandler( | |
body, | |
query, | |
cookies: Object.fromEntries( | |
- cookies() | |
- .getAll() | |
- .map((c) => [c.name, c.value]) | |
+ Array.from(req.cookies.entries()) | |
+ .map(([name, value]) => [name, value]) | |
), | |
- headers: Object.fromEntries(headers() as Headers), | |
+ headers: req.headers as Headers, | |
method: req.method, | |
action: nextauth?.[0] as AuthAction, | |
providerId: nextauth?.[1], | |
@@ -180,25 +178,9 @@ export async function getServerSession< | |
const isRSC = args.length === 0 || args.length === 1 | |
let req, res, options: AuthOptions | |
- if (isRSC) { | |
- options = Object.assign({}, args[0], { providers: [] }) | |
- | |
- // eslint-disable-next-line @typescript-eslint/no-var-requires | |
- const { headers, cookies } = require("next/headers") | |
- req = { | |
- headers: Object.fromEntries(headers() as Headers), | |
- cookies: Object.fromEntries( | |
- cookies() | |
- .getAll() | |
- .map((c) => [c.name, c.value]) | |
- ), | |
- } | |
- res = { getHeader() {}, setCookie() {}, setHeader() {} } | |
- } else { | |
- req = args[0] | |
- res = args[1] | |
- options = Object.assign({}, args[2], { providers: [] }) | |
- } | |
+ req = args[0] | |
+ res = args[1] | |
+ options = Object.assign({}, args[2], { providers: [] }) | |
options.secret ??= process.env.NEXTAUTH_SECRET | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment