diff options
Diffstat (limited to '')
-rw-r--r-- | packages/astro/src/core/app/index.ts | 8 | ||||
-rw-r--r-- | packages/astro/src/core/endpoint/index.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/vite-plugin-astro-server/index.ts | 12 |
3 files changed, 17 insertions, 5 deletions
diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index f443ffeac..e3d2bbe11 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -9,7 +9,7 @@ import type { LogOptions } from '../logger/core.js'; import type { RouteInfo, SSRManifest as Manifest } from './types'; import mime from 'mime'; -import { getSetCookiesFromResponse } from '../cookies/index.js'; +import { attachToResponse, getSetCookiesFromResponse } from '../cookies/index.js'; import { call as callEndpoint } from '../endpoint/index.js'; import { consoleLogDestination } from '../logger/console.js'; import { error } from '../logger/core.js'; @@ -236,10 +236,14 @@ export class App { } const bytes = this.#encoder.encode(body); headers.set('Content-Length', bytes.byteLength.toString()); - return new Response(bytes, { + + const response = new Response(bytes, { status: 200, headers, }); + + attachToResponse(response, result.cookies); + return response; } } } diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts index f5407d7c5..79102f8b1 100644 --- a/packages/astro/src/core/endpoint/index.ts +++ b/packages/astro/src/core/endpoint/index.ts @@ -13,6 +13,7 @@ type EndpointCallResult = type: 'simple'; body: string; encoding?: BufferEncoding; + cookies: AstroCookies; } | { type: 'response'; @@ -109,5 +110,6 @@ export async function call( type: 'simple', body: response.body, encoding: response.encoding, + cookies: context.cookies, }; } diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index 2039c0a86..049dc4615 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -5,7 +5,7 @@ import type { AstroSettings, ManifestData } from '../@types/astro'; import { DevelopmentEnvironment, SSROptions } from '../core/render/dev/index'; import { Readable } from 'stream'; -import { getSetCookiesFromResponse } from '../core/cookies/index.js'; +import { attachToResponse, getSetCookiesFromResponse } from '../core/cookies/index.js'; import { call as callEndpoint } from '../core/endpoint/dev/index.js'; import { collectErrorMetadata, @@ -378,8 +378,14 @@ async function handleRoute( if (computedMimeType) { contentType = computedMimeType; } - res.writeHead(200, { 'Content-Type': `${contentType};charset=utf-8` }); - res.end(result.body); + const response = new Response(result.body, { + status: 200, + headers: { + 'Content-Type': `${contentType};charset=utf-8`, + }, + }); + attachToResponse(response, result.cookies); + await writeWebResponse(res, response); } } else { const result = await renderPage(options); |