UNPKG

astro

Version:

Astro is a modern site builder with web best practices, performance, and DX front-of-mind.

18 lines (17 loc) • 653 B
import { responseSentSymbol } from "../constants.js"; import { getSetCookiesFromResponse } from "../cookies/index.js"; /** * Appends cookies written via `Astro.cookie.set()` to the `Set-Cookie` header * and marks the response as sent. * * This is a pure function with no dependencies on the app; it is shared by * `handleRequest` and the various error handlers. */ export function prepareResponse(response, { addCookieHeader }) { if (addCookieHeader) { for (const setCookieHeaderValue of getSetCookiesFromResponse(response)) { response.headers.append("set-cookie", setCookieHeaderValue); } } Reflect.set(response, responseSentSymbol, true); }