Skip to content

Commit

Permalink
Fix cookies().set missing in types (#49806)
Browse files Browse the repository at this point in the history
Closes #49259. Note that even if we allow `.set` in the types, it will still error when called in wrong places (such as Server Components).
fix NEXT-1090
  • Loading branch information
shuding committed May 15, 2023
1 parent afddb6e commit ca32dec
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -12,7 +12,7 @@ import { ReflectAdapter } from './reflect'
export class ReadonlyRequestCookiesError extends Error {
constructor() {
super(
'ReadonlyRequestCookies cannot be modified. Read more: https://nextjs.org/docs/api-reference/cookies'
'Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options'
)
}

Expand All @@ -21,10 +21,7 @@ export class ReadonlyRequestCookiesError extends Error {
}
}

export type ReadonlyRequestCookies = Omit<
RequestCookies,
'clear' | 'delete' | 'set'
>
export type ReadonlyRequestCookies = Omit<RequestCookies, 'clear' | 'delete'>

export class RequestCookiesAdapter {
public static seal(cookies: RequestCookies): ReadonlyRequestCookies {
Expand Down

1 comment on commit ca32dec

@0-don
Copy link

@0-don 0-don commented on ca32dec May 15, 2023

Choose a reason for hiding this comment

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

when will we be able to set cookies via server components?

Please sign in to comment.