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

Fix return type of middleware req.cookies.get() #36872

Merged
merged 3 commits into from May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/next/server/web/spec-extension/cookies.ts
Expand Up @@ -35,7 +35,7 @@ const deserializeCookie = (input: Request | Response): string[] => {

const serializeCookie = (input: string[]) => input.join(', ')

export class Cookies extends Map<string, any> {
export class Cookies extends Map<string, string> {
ijjk marked this conversation as resolved.
Show resolved Hide resolved
constructor(input?: string | null) {
const parsedInput = typeof input === 'string' ? cookie.parse(input) : {}
super(Object.entries(parsedInput))
Expand Down
Expand Up @@ -10,6 +10,9 @@ export const middleware: NextMiddleware = async function (request) {
const response = NextResponse.rewrite(`/rewrites/${bucket}`)
response.cookies.set('bucket', bucket, { maxAge: 10 })
return response
} else {
// check that `bucket` is type "string", not "any"
bucket.toUpperCase()
}

return NextResponse.rewrite(`/rewrites/${bucket}`)
Expand Down