edge-runtime icon indicating copy to clipboard operation
edge-runtime copied to clipboard

feat: add @edge-runtime/cookies helpers

Open Schniz opened this issue 2 years ago • 2 comments

This provides utilities to handle with cookie parsing & manipulating with Request/Response objects.

The code was copied from the Next.js repo, to provide these utilities to other frameworks so they can reuse this logic when they deploy to any Edge Runtime-compatible service.

Schniz avatar Aug 10 '22 12:08 Schniz

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
edge-runtime ✅ Ready (Inspect) Visit Preview Aug 23, 2022 at 11:18AM (UTC)

vercel[bot] avatar Aug 10 '22 12:08 vercel[bot]

discussion:

I feel like Cookies can have a better API, or at least a .commit(headers) method (or, commit(cookies, headers) function) that will make ManipulateHeadersCookies much simpler.

Maybe even

type CookiesOptions = {
  onCookieChanges(name: string, value: string, options: CookieOptions): void
};
class Cookies extends Map<string, string> {
  constructor(cookieHeader: string | null | undefined, private readonly options: CookiesOptions) {
    // ...
  }
}

🤔

Schniz avatar Aug 11 '22 12:08 Schniz

I'm gonna open a new PR for this

Schniz avatar Aug 23 '22 11:08 Schniz