Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-olives-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
---

Updates the `AstroCookieSetOptions` type exported from `astro` to allow partitioned cookies
Comment thread
Princesseuh marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions packages/astro/src/core/config/schemas/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const AstroConfigSchema = z.object({
maxAge: z.number().optional(),
sameSite: z.union([z.enum(['strict', 'lax', 'none']), z.boolean()]).optional(),
secure: z.boolean().optional(),
partitioned: z.boolean().optional(),
})
.or(z.string())
.transform((val) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/cookies/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AstroError, AstroErrorData } from '../errors/index.js';

export type AstroCookieSetOptions = Pick<
SerializeOptions,
'domain' | 'path' | 'expires' | 'maxAge' | 'httpOnly' | 'sameSite' | 'secure' | 'encode'
'domain' | 'path' | 'expires' | 'maxAge' | 'httpOnly' | 'sameSite' | 'secure' | 'encode' | 'partitioned'
>;

export interface AstroCookieGetOptions {
Expand Down
12 changes: 12 additions & 0 deletions packages/integrations/netlify/test/functions/cookies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ describe(
assert.deepEqual(resp.headers.getSetCookie(), ['foo=foo; HttpOnly', 'bar=bar; HttpOnly']);
});

it('Can set partitioned cookie', async () => {
const entryURL = new URL(
'./fixtures/cookies/.netlify/v1/functions/ssr/ssr.mjs',
import.meta.url,
);
const { default: handler } = await import(entryURL);
const resp = await handler(new Request('http://example.com/partitioned'), {});
assert.equal(resp.status, 200);
const cookie = resp.headers.getSetCookie()[0];
assert.ok(cookie.includes('Partitioned'), 'Cookie should include Partitioned attribute');
});

it('renders dynamic 404 page', async () => {
const entryURL = new URL(
'./fixtures/cookies/.netlify/v1/functions/ssr/ssr.mjs',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

export function GET({ cookies }) {
cookies.set('partitioned-cookie', 'value', { partitioned: true, secure: true });
return new Response('ok');
}
Loading