diff --git a/.changeset/old-fireants-allow.md b/.changeset/old-fireants-allow.md new file mode 100644 index 000000000000..4857a7a7cdad --- /dev/null +++ b/.changeset/old-fireants-allow.md @@ -0,0 +1,5 @@ +--- +'@astrojs/lit': patch +--- + +Render DSD attributes based on `shadowRootOptions` diff --git a/.changeset/yellow-kings-rhyme.md b/.changeset/yellow-kings-rhyme.md new file mode 100644 index 000000000000..9b0729772841 --- /dev/null +++ b/.changeset/yellow-kings-rhyme.md @@ -0,0 +1,6 @@ +--- +'@astrojs/webapi': patch +'@astrojs/telemetry': patch +--- + +Update `undici` to v5.20.0 diff --git a/packages/astro/src/core/cookies/response.ts b/packages/astro/src/core/cookies/response.ts index d04ce1ef3848..18d72ab1c77b 100644 --- a/packages/astro/src/core/cookies/response.ts +++ b/packages/astro/src/core/cookies/response.ts @@ -15,12 +15,14 @@ function getFromResponse(response: Response): AstroCookies | undefined { } } -export function* getSetCookiesFromResponse(response: Response): Generator { +export function* getSetCookiesFromResponse(response: Response): Generator { const cookies = getFromResponse(response); if (!cookies) { - return; + return []; } for (const headerValue of cookies.headers()) { yield headerValue; } + + return []; } diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index 008e7daabdc9..a7cc6e093609 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -55,19 +55,24 @@ export function writeHtmlResponse(res: http.ServerResponse, statusCode: number, export async function writeWebResponse(res: http.ServerResponse, webResponse: Response) { const { status, headers, body } = webResponse; + // Attach any set-cookie headers added via Astro.cookies.set() + const setCookieHeaders = Array.from(getSetCookiesFromResponse(webResponse)); + setCookieHeaders.forEach((cookie) => { + headers.append('set-cookie', cookie); + }); + const _headers = Object.fromEntries(headers.entries()); // Undici 5.20.0+ includes a `getSetCookie` helper that returns an array of all the `set-cookies` headers. // Previously, `headers.entries()` would already have these merged, but it seems like this isn't the case anymore. - if ('getSetCookie' in headers && typeof headers.getSetCookie === 'function') { - _headers['set-cookie'] = headers.getSetCookie(); + if (headers.has('set-cookie')) { + if ('getSetCookie' in headers && typeof headers.getSetCookie === 'function') { + _headers['set-cookie'] = headers.getSetCookie(); + } else { + _headers['set-cookie'] = headers.get('set-cookie')!; + } } - // Attach any set-cookie headers added via Astro.cookies.set() - const setCookieHeaders = Array.from(getSetCookiesFromResponse(webResponse)); - if (setCookieHeaders.length) { - res.setHeader('Set-Cookie', setCookieHeaders); - } res.writeHead(status, _headers); if (body) { if (Symbol.for('astro.responseBody') in webResponse) { diff --git a/packages/integrations/lit/server.js b/packages/integrations/lit/server.js index da571466f498..aa91d1ea8c65 100644 --- a/packages/integrations/lit/server.js +++ b/packages/integrations/lit/server.js @@ -62,7 +62,11 @@ function* render(Component, attrs, slots) { yield `>`; const shadowContents = instance.renderShadow({}); if (shadowContents !== undefined) { - yield '