Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[edge] support request.cookies as a map #4745

Merged
merged 1 commit into from Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/next-auth/src/core/lib/cookie.ts
Expand Up @@ -120,7 +120,7 @@ export class SessionStore {
constructor(
option: CookieOption,
req: {
cookies?: Record<string, string>
cookies?: Record<string, string> | { get: (key: string) => string }
headers?: Headers | IncomingHttpHeaders | Record<string, string>
},
logger: LoggerInstance | Console
Expand All @@ -132,7 +132,10 @@ export class SessionStore {

for (const name in req.cookies) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Schniz & @balazsorban44
I think this needs to be a for-of loop for Map to work.
I'm running into this issue where the cookie isn't being read in the middleware
The for-in loop just iterates the properties of the Map object and not the actual constants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right

if (name.startsWith(option.name)) {
this.#chunks[name] = req.cookies[name]
this.#chunks[name] =
typeof req.cookies.get === "function"
? req.cookies.get(name)
: req.cookies[name]
}
}
}
Expand Down