MCPcopy
hub / github.com/GitbookIO/gitbook / writeResponseCookies

Function writeResponseCookies

packages/gitbook/src/middleware.ts:617–630  ·  view source on GitHub ↗

* Write the cookies to a response.

(
    response: R,
    cookiesToSet: ResponseCookies
)

Source from the content-addressed store, hash-verified

615 * Write the cookies to a response.
616 */
617async function writeResponseCookies<R extends NextResponse>(
618 response: R,
619 cookiesToSet: ResponseCookies
620): Promise<R> {
621 const cookiesFn = await cookies();
622 cookiesToSet.forEach((cookie) => {
623 // response.cookies.set(cookie.name, cookie.value, cookie.options);
624 // For some reason we have to use the cookies function instead of response.cookies.set
625 // Without it, it breaks the ai assistant server actions (it thinks it is a static route).
626 cookiesFn.set(cookie.name, cookie.value, cookie.options);
627 });
628
629 return response;
630}

Callers 2

withAPITokenFunction · 0.85
serveWithQueryAPITokenFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected