@prismicio/next 2.3.1-pr.147.3d90e76 → 2.3.1-pr.147.8743809

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
23
23
  });
24
24
  declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
25
25
  children?: React.ReactNode | undefined;
26
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
26
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
27
27
  linkResolver?: LinkResolverFunction;
28
28
  rel?: string | AsLinkAttrsConfig["rel"];
29
29
  } & {
@@ -32,7 +32,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
32
32
  href?: never;
33
33
  }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
34
34
  children?: React.ReactNode | undefined;
35
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
35
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
36
36
  linkResolver?: LinkResolverFunction;
37
37
  rel?: string | AsLinkAttrsConfig["rel"];
38
38
  } & {
@@ -41,7 +41,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
41
41
  href?: never;
42
42
  }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
43
43
  children?: React.ReactNode | undefined;
44
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
44
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
45
45
  linkResolver?: LinkResolverFunction;
46
46
  rel?: string | AsLinkAttrsConfig["rel"];
47
47
  } & {
@@ -23,7 +23,7 @@ type PrismicNextLinkProps = Omit<ComponentProps<typeof Link>, "field" | "documen
23
23
  });
24
24
  declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
25
25
  children?: React.ReactNode | undefined;
26
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
26
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
27
27
  linkResolver?: LinkResolverFunction;
28
28
  rel?: string | AsLinkAttrsConfig["rel"];
29
29
  } & {
@@ -32,7 +32,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
32
32
  href?: never;
33
33
  }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
34
34
  children?: React.ReactNode | undefined;
35
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
35
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
36
36
  linkResolver?: LinkResolverFunction;
37
37
  rel?: string | AsLinkAttrsConfig["rel"];
38
38
  } & {
@@ -41,7 +41,7 @@ declare const PrismicNextLink: _$react.ForwardRefExoticComponent<(Omit<Omit<Omit
41
41
  href?: never;
42
42
  }, "ref"> | Omit<Omit<Omit<_$react.AnchorHTMLAttributes<HTMLAnchorElement>, keyof _$next_link0.LinkProps<any>> & _$next_link0.LinkProps<any> & {
43
43
  children?: React.ReactNode | undefined;
44
- } & _$react.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
44
+ } & _$react.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
45
45
  linkResolver?: LinkResolverFunction;
46
46
  rel?: string | AsLinkAttrsConfig["rel"];
47
47
  } & {
@@ -1,6 +1,4 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
1
  const require_expiredPreviewCookies = require("./lib/expiredPreviewCookies.cjs");
3
- let _prismicio_client = require("@prismicio/client");
4
2
  //#region src/exitPreview.ts
5
3
  /**
6
4
  * Ends a Prismic preview session within a Next.js app. This function should be used in a Router
@@ -18,12 +16,8 @@ let _prismicio_client = require("@prismicio/client");
18
16
  * ```
19
17
  */
20
18
  async function exitPreview() {
21
- const { cookies, draftMode } = await import("next/headers.js");
22
- (await draftMode()).disable();
23
- const cookieJar = await cookies();
24
- for (const options of require_expiredPreviewCookies.expiredPreviewCookieSetOptions) cookieJar.set(_prismicio_client.cookie.preview, "", options);
25
19
  const headers = new Headers({ "Cache-Control": "no-store" });
26
- for (const setCookie of require_expiredPreviewCookies.expiredPreviewCookieHeaders()) headers.append("Set-Cookie", setCookie);
20
+ for (const setCookie of [...require_expiredPreviewCookies.expiredPreviewCookieHeaders(), ...require_expiredPreviewCookies.expiredDraftModeCookieHeaders()]) headers.append("Set-Cookie", setCookie);
27
21
  return new Response(JSON.stringify({ success: true }), { headers });
28
22
  }
29
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"exitPreview.cjs","names":["expiredPreviewCookieSetOptions","prismicCookie","expiredPreviewCookieHeaders"],"sources":["../src/exitPreview.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nimport {\n\texpiredPreviewCookieHeaders,\n\texpiredPreviewCookieSetOptions,\n} from \"./lib/expiredPreviewCookies\"\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\t;(await draftMode()).disable()\n\n\t// `redirectToPreviewURL` writes SameSite=None; Secure. The toolbar may\n\t// leave SameSite=Lax (not Secure). Those are different cookies to Chrome.\n\t// Expire both. Do not use `cookies().delete()`: on Next.js 13.4.5–15 it\n\t// omits Secure/SameSite. `cookies()` is name-keyed, so also emit both\n\t// Set-Cookie headers on the Response.\n\tconst cookieJar = await cookies()\n\tfor (const options of expiredPreviewCookieSetOptions) {\n\t\tcookieJar.set(prismicCookie.preview, \"\", options)\n\t}\n\n\tconst headers = new Headers({\n\t\t\"Cache-Control\": \"no-store\",\n\t})\n\tfor (const setCookie of expiredPreviewCookieHeaders()) {\n\t\theaders.append(\"Set-Cookie\", setCookie)\n\t}\n\n\treturn new Response(JSON.stringify({ success: true }), { headers })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,eAAsB,cAAiC;CAItD,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;AAE3C,EAAC,MAAM,WAAW,EAAE,SAAS;CAO9B,MAAM,YAAY,MAAM,SAAS;AACjC,MAAK,MAAM,WAAWA,8BAAAA,+BACrB,WAAU,IAAIC,kBAAAA,OAAc,SAAS,IAAI,QAAQ;CAGlD,MAAM,UAAU,IAAI,QAAQ,EAC3B,iBAAiB,YACjB,CAAC;AACF,MAAK,MAAM,aAAaC,8BAAAA,6BAA6B,CACpD,SAAQ,OAAO,cAAc,UAAU;AAGxC,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC"}
1
+ {"version":3,"file":"exitPreview.cjs","names":["expiredPreviewCookieHeaders","expiredDraftModeCookieHeaders"],"sources":["../src/exitPreview.ts"],"sourcesContent":["import {\n\texpiredDraftModeCookieHeaders,\n\texpiredPreviewCookieHeaders,\n} from \"./lib/expiredPreviewCookies\"\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Do not call `cookies()` or `draftMode().disable()`. ResponseCookies is\n\t// name-keyed: `appendMutableCookies` rebuilds Set-Cookie by name and drops\n\t// the extra Lax expire. Emit every expire on the Response instead:\n\t// toolbar Lax + iframe None; Secure for `io.prismic.preview`, and both\n\t// shapes of `__prerender_bypass` that `disable()` would have cleared.\n\tconst headers = new Headers({\n\t\t\"Cache-Control\": \"no-store\",\n\t})\n\tfor (const setCookie of [...expiredPreviewCookieHeaders(), ...expiredDraftModeCookieHeaders()]) {\n\t\theaders.append(\"Set-Cookie\", setCookie)\n\t}\n\n\treturn new Response(JSON.stringify({ success: true }), { headers })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,eAAsB,cAAiC;CAMtD,MAAM,UAAU,IAAI,QAAQ,EAC3B,iBAAiB,YACjB,CAAC;AACF,MAAK,MAAM,aAAa,CAAC,GAAGA,8BAAAA,6BAA6B,EAAE,GAAGC,8BAAAA,+BAA+B,CAAC,CAC7F,SAAQ,OAAO,cAAc,UAAU;AAGxC,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../src/exitPreview.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;iBAAsB,WAAA,CAAA,GAAe,OAAA,CAAQ,QAAA"}
1
+ {"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../src/exitPreview.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;iBAAsB,WAAA,CAAA,GAAe,OAAA,CAAQ,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../src/exitPreview.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;iBAAsB,WAAA,CAAA,GAAe,OAAA,CAAQ,QAAA"}
1
+ {"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../src/exitPreview.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;iBAAsB,WAAA,CAAA,GAAe,OAAA,CAAQ,QAAA"}
@@ -1,5 +1,4 @@
1
- import { expiredPreviewCookieHeaders, expiredPreviewCookieSetOptions } from "./lib/expiredPreviewCookies.js";
2
- import { cookie } from "@prismicio/client";
1
+ import { expiredDraftModeCookieHeaders, expiredPreviewCookieHeaders } from "./lib/expiredPreviewCookies.js";
3
2
  //#region src/exitPreview.ts
4
3
  /**
5
4
  * Ends a Prismic preview session within a Next.js app. This function should be used in a Router
@@ -17,12 +16,8 @@ import { cookie } from "@prismicio/client";
17
16
  * ```
18
17
  */
19
18
  async function exitPreview() {
20
- const { cookies, draftMode } = await import("next/headers.js");
21
- (await draftMode()).disable();
22
- const cookieJar = await cookies();
23
- for (const options of expiredPreviewCookieSetOptions) cookieJar.set(cookie.preview, "", options);
24
19
  const headers = new Headers({ "Cache-Control": "no-store" });
25
- for (const setCookie of expiredPreviewCookieHeaders()) headers.append("Set-Cookie", setCookie);
20
+ for (const setCookie of [...expiredPreviewCookieHeaders(), ...expiredDraftModeCookieHeaders()]) headers.append("Set-Cookie", setCookie);
26
21
  return new Response(JSON.stringify({ success: true }), { headers });
27
22
  }
28
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"exitPreview.js","names":["prismicCookie"],"sources":["../src/exitPreview.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nimport {\n\texpiredPreviewCookieHeaders,\n\texpiredPreviewCookieSetOptions,\n} from \"./lib/expiredPreviewCookies\"\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\t;(await draftMode()).disable()\n\n\t// `redirectToPreviewURL` writes SameSite=None; Secure. The toolbar may\n\t// leave SameSite=Lax (not Secure). Those are different cookies to Chrome.\n\t// Expire both. Do not use `cookies().delete()`: on Next.js 13.4.5–15 it\n\t// omits Secure/SameSite. `cookies()` is name-keyed, so also emit both\n\t// Set-Cookie headers on the Response.\n\tconst cookieJar = await cookies()\n\tfor (const options of expiredPreviewCookieSetOptions) {\n\t\tcookieJar.set(prismicCookie.preview, \"\", options)\n\t}\n\n\tconst headers = new Headers({\n\t\t\"Cache-Control\": \"no-store\",\n\t})\n\tfor (const setCookie of expiredPreviewCookieHeaders()) {\n\t\theaders.append(\"Set-Cookie\", setCookie)\n\t}\n\n\treturn new Response(JSON.stringify({ success: true }), { headers })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,eAAsB,cAAiC;CAItD,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;AAE3C,EAAC,MAAM,WAAW,EAAE,SAAS;CAO9B,MAAM,YAAY,MAAM,SAAS;AACjC,MAAK,MAAM,WAAW,+BACrB,WAAU,IAAIA,OAAc,SAAS,IAAI,QAAQ;CAGlD,MAAM,UAAU,IAAI,QAAQ,EAC3B,iBAAiB,YACjB,CAAC;AACF,MAAK,MAAM,aAAa,6BAA6B,CACpD,SAAQ,OAAO,cAAc,UAAU;AAGxC,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC"}
1
+ {"version":3,"file":"exitPreview.js","names":[],"sources":["../src/exitPreview.ts"],"sourcesContent":["import {\n\texpiredDraftModeCookieHeaders,\n\texpiredPreviewCookieHeaders,\n} from \"./lib/expiredPreviewCookies\"\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in a Router\n * Handler.\n *\n * @example\n * \t;```typescript\n * \t// src/app/api/exit-preview/route.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport async function GET() {\n * \t\treturn await exitPreview()\n * \t}\n * \t```\n */\nexport async function exitPreview(): Promise<Response> {\n\t// Do not call `cookies()` or `draftMode().disable()`. ResponseCookies is\n\t// name-keyed: `appendMutableCookies` rebuilds Set-Cookie by name and drops\n\t// the extra Lax expire. Emit every expire on the Response instead:\n\t// toolbar Lax + iframe None; Secure for `io.prismic.preview`, and both\n\t// shapes of `__prerender_bypass` that `disable()` would have cleared.\n\tconst headers = new Headers({\n\t\t\"Cache-Control\": \"no-store\",\n\t})\n\tfor (const setCookie of [...expiredPreviewCookieHeaders(), ...expiredDraftModeCookieHeaders()]) {\n\t\theaders.append(\"Set-Cookie\", setCookie)\n\t}\n\n\treturn new Response(JSON.stringify({ success: true }), { headers })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,eAAsB,cAAiC;CAMtD,MAAM,UAAU,IAAI,QAAQ,EAC3B,iBAAiB,YACjB,CAAC;AACF,MAAK,MAAM,aAAa,CAAC,GAAG,6BAA6B,EAAE,GAAG,+BAA+B,CAAC,CAC7F,SAAQ,OAAO,cAAc,UAAU;AAGxC,QAAO,IAAI,SAAS,KAAK,UAAU,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC"}
@@ -29,7 +29,6 @@ async function getPreviewRef() {
29
29
  if (!isDraftModeEnabled) return;
30
30
  const cookie = (await cookies()).get(_prismicio_client.cookie.preview)?.value;
31
31
  if (!cookie) return;
32
- if (!cookie.includes("websitePreviewId=")) return;
33
32
  return cookie;
34
33
  }
35
34
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewRef.cjs","names":["prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\")\n\tif (!isActiveCookie) {\n\t\treturn\n\t}\n\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAM,UAAU,MAAM,SAAS,EAAE,IAAIA,kBAAAA,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAAC,OACJ;AAID,KAAI,CADmB,OAAO,SAAS,oBAAoB,CAE1D;AAGD,QAAO"}
1
+ {"version":3,"file":"getPreviewRef.cjs","names":["prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\t// Draft Mode gates preview reads; the Content API validates the opaque ref.\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAM,UAAU,MAAM,SAAS,EAAE,IAAIA,kBAAAA,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAAC,OACJ;AAID,QAAO"}
@@ -28,7 +28,6 @@ async function getPreviewRef() {
28
28
  if (!isDraftModeEnabled) return;
29
29
  const cookie$1 = (await cookies()).get(cookie.preview)?.value;
30
30
  if (!cookie$1) return;
31
- if (!cookie$1.includes("websitePreviewId=")) return;
32
31
  return cookie$1;
33
32
  }
34
33
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewRef.js","names":["cookie","prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\tconst isActiveCookie = cookie.includes(\"websitePreviewId=\")\n\tif (!isActiveCookie) {\n\t\treturn\n\t}\n\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAMA,YAAU,MAAM,SAAS,EAAE,IAAIC,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAACD,SACJ;AAID,KAAI,CADmBA,SAAO,SAAS,oBAAoB,CAE1D;AAGD,QAAOA"}
1
+ {"version":3,"file":"getPreviewRef.js","names":["cookie","prismicCookie"],"sources":["../src/getPreviewRef.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\n/**\n * Reads the Prismic preview ref for the current request when an active preview session exists.\n *\n * This is the read-side counterpart to `redirectToPreviewURL`, which writes the preview cookie. Use\n * it with Next.js Cache Components to read the ref _outside_ a cached function and pass it _in_ as\n * an argument so it becomes part of the cache key:\n *\n * @example\n * \t;```typescript\n * \timport { getPreviewRef } from \"@prismicio/next\"\n *\n * \tconst page = await fetchPage(uid, await getPreviewRef())\n * \t```\n *\n * @returns The active preview ref, or `undefined` if no preview session is active.\n * @experimental\n */\nexport async function getPreviewRef(): Promise<string | undefined> {\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { cookies, draftMode } = await import(\"next/headers\")\n\n\tlet isDraftModeEnabled = false\n\ttry {\n\t\tisDraftModeEnabled = (await draftMode()).isEnabled\n\t} catch {\n\t\t// `draftMode()` may have been called in a place that\n\t\t// does not have access to its async storage. This\n\t\t// occurs in places like `generateStaticParams()`. We\n\t\t// can ignore this case.\n\t\treturn\n\t}\n\tif (!isDraftModeEnabled) {\n\t\treturn\n\t}\n\n\tconst cookie = (await cookies()).get(prismicCookie.preview)?.value\n\tif (!cookie) {\n\t\treturn\n\t}\n\n\t// Draft Mode gates preview reads; the Content API validates the opaque ref.\n\treturn cookie\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAAsB,gBAA6C;CAIlE,MAAM,EAAE,SAAS,cAAc,MAAM,OAAO;CAE5C,IAAI,qBAAqB;AACzB,KAAI;AACH,wBAAsB,MAAM,WAAW,EAAE;SAClC;AAKP;;AAED,KAAI,CAAC,mBACJ;CAGD,MAAMA,YAAU,MAAM,SAAS,EAAE,IAAIC,OAAc,QAAQ,EAAE;AAC7D,KAAI,CAACD,SACJ;AAID,QAAOA"}
@@ -2,33 +2,26 @@ require("../_virtual/_rolldown/runtime.cjs");
2
2
  let _prismicio_client = require("@prismicio/client");
3
3
  //#region src/lib/expiredPreviewCookies.ts
4
4
  const epoch = /* @__PURE__ */ new Date(0);
5
- /**
6
- * `cookies().set` options that expire both leftover shapes of `io.prismic.preview`: toolbar Lax
7
- * (not Secure) and the iframe write (SameSite=None; Secure).
8
- *
9
- * `cookies()` is name-keyed, so a Route Handler must also emit both `Set-Cookie` headers from
10
- * {@link expiredPreviewCookieHeaders}.
11
- */
12
- const expiredPreviewCookieSetOptions = [{
13
- path: "/",
14
- sameSite: "lax",
15
- secure: false,
16
- httpOnly: false,
17
- expires: epoch
18
- }, {
19
- path: "/",
20
- sameSite: "none",
21
- secure: true,
22
- httpOnly: false,
23
- expires: epoch
24
- }];
5
+ function expiresAttr() {
6
+ return `Expires=${epoch.toUTCString()}`;
7
+ }
25
8
  /** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */
26
9
  function expiredPreviewCookieHeaders(name = _prismicio_client.cookie.preview) {
27
- const expires = `Expires=${epoch.toUTCString()}`;
10
+ const expires = expiresAttr();
28
11
  return [`${name}=; Path=/; ${expires}; SameSite=Lax`, `${name}=; Path=/; ${expires}; SameSite=None; Secure`];
29
12
  }
13
+ /**
14
+ * Expired `Set-Cookie` values for the App Router draft-mode cookie that `draftMode().disable()`
15
+ * would clear. Next sets `__prerender_bypass` as Lax (not Secure) in development and SameSite=None;
16
+ * Secure in production.
17
+ */
18
+ function expiredDraftModeCookieHeaders() {
19
+ const expires = expiresAttr();
20
+ const name = "__prerender_bypass";
21
+ return [`${name}=; Path=/; ${expires}; SameSite=Lax; HttpOnly`, `${name}=; Path=/; ${expires}; SameSite=None; Secure; HttpOnly`];
22
+ }
30
23
  //#endregion
24
+ exports.expiredDraftModeCookieHeaders = expiredDraftModeCookieHeaders;
31
25
  exports.expiredPreviewCookieHeaders = expiredPreviewCookieHeaders;
32
- exports.expiredPreviewCookieSetOptions = expiredPreviewCookieSetOptions;
33
26
 
34
27
  //# sourceMappingURL=expiredPreviewCookies.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"expiredPreviewCookies.cjs","names":["prismicCookie"],"sources":["../../src/lib/expiredPreviewCookies.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nconst epoch = new Date(0)\n\n/**\n * `cookies().set` options that expire both leftover shapes of `io.prismic.preview`: toolbar Lax\n * (not Secure) and the iframe write (SameSite=None; Secure).\n *\n * `cookies()` is name-keyed, so a Route Handler must also emit both `Set-Cookie` headers from\n * {@link expiredPreviewCookieHeaders}.\n */\nexport const expiredPreviewCookieSetOptions = [\n\t{\n\t\tpath: \"/\",\n\t\tsameSite: \"lax\",\n\t\tsecure: false,\n\t\thttpOnly: false,\n\t\texpires: epoch,\n\t},\n\t{\n\t\tpath: \"/\",\n\t\tsameSite: \"none\",\n\t\tsecure: true,\n\t\thttpOnly: false,\n\t\texpires: epoch,\n\t},\n] as const\n\n/** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */\nexport function expiredPreviewCookieHeaders(name = prismicCookie.preview): string[] {\n\tconst expires = `Expires=${epoch.toUTCString()}`\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure`,\n\t]\n}\n"],"mappings":";;;AAEA,MAAM,wBAAQ,IAAI,KAAK,EAAE;;;;;;;;AASzB,MAAa,iCAAiC,CAC7C;CACC,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,SAAS;CACT,EACD;CACC,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,SAAS;CACT,CACD;;AAGD,SAAgB,4BAA4B,OAAOA,kBAAAA,OAAc,SAAmB;CACnF,MAAM,UAAU,WAAW,MAAM,aAAa;AAE9C,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,iBAC7B,GAAG,KAAK,aAAa,QAAQ,yBAC7B"}
1
+ {"version":3,"file":"expiredPreviewCookies.cjs","names":["prismicCookie"],"sources":["../../src/lib/expiredPreviewCookies.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nconst epoch = new Date(0)\n\nfunction expiresAttr(): string {\n\treturn `Expires=${epoch.toUTCString()}`\n}\n\n/** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */\nexport function expiredPreviewCookieHeaders(name = prismicCookie.preview): string[] {\n\tconst expires = expiresAttr()\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure`,\n\t]\n}\n\n/**\n * Expired `Set-Cookie` values for the App Router draft-mode cookie that `draftMode().disable()`\n * would clear. Next sets `__prerender_bypass` as Lax (not Secure) in development and SameSite=None;\n * Secure in production.\n */\nexport function expiredDraftModeCookieHeaders(): string[] {\n\tconst expires = expiresAttr()\n\tconst name = \"__prerender_bypass\"\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax; HttpOnly`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure; HttpOnly`,\n\t]\n}\n"],"mappings":";;;AAEA,MAAM,wBAAQ,IAAI,KAAK,EAAE;AAEzB,SAAS,cAAsB;AAC9B,QAAO,WAAW,MAAM,aAAa;;;AAItC,SAAgB,4BAA4B,OAAOA,kBAAAA,OAAc,SAAmB;CACnF,MAAM,UAAU,aAAa;AAE7B,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,iBAC7B,GAAG,KAAK,aAAa,QAAQ,yBAC7B;;;;;;;AAQF,SAAgB,gCAA0C;CACzD,MAAM,UAAU,aAAa;CAC7B,MAAM,OAAO;AAEb,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,2BAC7B,GAAG,KAAK,aAAa,QAAQ,mCAC7B"}
@@ -1,32 +1,25 @@
1
1
  import { cookie } from "@prismicio/client";
2
2
  //#region src/lib/expiredPreviewCookies.ts
3
3
  const epoch = /* @__PURE__ */ new Date(0);
4
- /**
5
- * `cookies().set` options that expire both leftover shapes of `io.prismic.preview`: toolbar Lax
6
- * (not Secure) and the iframe write (SameSite=None; Secure).
7
- *
8
- * `cookies()` is name-keyed, so a Route Handler must also emit both `Set-Cookie` headers from
9
- * {@link expiredPreviewCookieHeaders}.
10
- */
11
- const expiredPreviewCookieSetOptions = [{
12
- path: "/",
13
- sameSite: "lax",
14
- secure: false,
15
- httpOnly: false,
16
- expires: epoch
17
- }, {
18
- path: "/",
19
- sameSite: "none",
20
- secure: true,
21
- httpOnly: false,
22
- expires: epoch
23
- }];
4
+ function expiresAttr() {
5
+ return `Expires=${epoch.toUTCString()}`;
6
+ }
24
7
  /** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */
25
8
  function expiredPreviewCookieHeaders(name = cookie.preview) {
26
- const expires = `Expires=${epoch.toUTCString()}`;
9
+ const expires = expiresAttr();
27
10
  return [`${name}=; Path=/; ${expires}; SameSite=Lax`, `${name}=; Path=/; ${expires}; SameSite=None; Secure`];
28
11
  }
12
+ /**
13
+ * Expired `Set-Cookie` values for the App Router draft-mode cookie that `draftMode().disable()`
14
+ * would clear. Next sets `__prerender_bypass` as Lax (not Secure) in development and SameSite=None;
15
+ * Secure in production.
16
+ */
17
+ function expiredDraftModeCookieHeaders() {
18
+ const expires = expiresAttr();
19
+ const name = "__prerender_bypass";
20
+ return [`${name}=; Path=/; ${expires}; SameSite=Lax; HttpOnly`, `${name}=; Path=/; ${expires}; SameSite=None; Secure; HttpOnly`];
21
+ }
29
22
  //#endregion
30
- export { expiredPreviewCookieHeaders, expiredPreviewCookieSetOptions };
23
+ export { expiredDraftModeCookieHeaders, expiredPreviewCookieHeaders };
31
24
 
32
25
  //# sourceMappingURL=expiredPreviewCookies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expiredPreviewCookies.js","names":["prismicCookie"],"sources":["../../src/lib/expiredPreviewCookies.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nconst epoch = new Date(0)\n\n/**\n * `cookies().set` options that expire both leftover shapes of `io.prismic.preview`: toolbar Lax\n * (not Secure) and the iframe write (SameSite=None; Secure).\n *\n * `cookies()` is name-keyed, so a Route Handler must also emit both `Set-Cookie` headers from\n * {@link expiredPreviewCookieHeaders}.\n */\nexport const expiredPreviewCookieSetOptions = [\n\t{\n\t\tpath: \"/\",\n\t\tsameSite: \"lax\",\n\t\tsecure: false,\n\t\thttpOnly: false,\n\t\texpires: epoch,\n\t},\n\t{\n\t\tpath: \"/\",\n\t\tsameSite: \"none\",\n\t\tsecure: true,\n\t\thttpOnly: false,\n\t\texpires: epoch,\n\t},\n] as const\n\n/** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */\nexport function expiredPreviewCookieHeaders(name = prismicCookie.preview): string[] {\n\tconst expires = `Expires=${epoch.toUTCString()}`\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure`,\n\t]\n}\n"],"mappings":";;AAEA,MAAM,wBAAQ,IAAI,KAAK,EAAE;;;;;;;;AASzB,MAAa,iCAAiC,CAC7C;CACC,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,SAAS;CACT,EACD;CACC,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,SAAS;CACT,CACD;;AAGD,SAAgB,4BAA4B,OAAOA,OAAc,SAAmB;CACnF,MAAM,UAAU,WAAW,MAAM,aAAa;AAE9C,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,iBAC7B,GAAG,KAAK,aAAa,QAAQ,yBAC7B"}
1
+ {"version":3,"file":"expiredPreviewCookies.js","names":["prismicCookie"],"sources":["../../src/lib/expiredPreviewCookies.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nconst epoch = new Date(0)\n\nfunction expiresAttr(): string {\n\treturn `Expires=${epoch.toUTCString()}`\n}\n\n/** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */\nexport function expiredPreviewCookieHeaders(name = prismicCookie.preview): string[] {\n\tconst expires = expiresAttr()\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure`,\n\t]\n}\n\n/**\n * Expired `Set-Cookie` values for the App Router draft-mode cookie that `draftMode().disable()`\n * would clear. Next sets `__prerender_bypass` as Lax (not Secure) in development and SameSite=None;\n * Secure in production.\n */\nexport function expiredDraftModeCookieHeaders(): string[] {\n\tconst expires = expiresAttr()\n\tconst name = \"__prerender_bypass\"\n\n\treturn [\n\t\t`${name}=; Path=/; ${expires}; SameSite=Lax; HttpOnly`,\n\t\t`${name}=; Path=/; ${expires}; SameSite=None; Secure; HttpOnly`,\n\t]\n}\n"],"mappings":";;AAEA,MAAM,wBAAQ,IAAI,KAAK,EAAE;AAEzB,SAAS,cAAsB;AAC9B,QAAO,WAAW,MAAM,aAAa;;;AAItC,SAAgB,4BAA4B,OAAOA,OAAc,SAAmB;CACnF,MAAM,UAAU,aAAa;AAE7B,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,iBAC7B,GAAG,KAAK,aAAa,QAAQ,yBAC7B;;;;;;;AAQF,SAAgB,gCAA0C;CACzD,MAAM,UAAU,aAAa;CAC7B,MAAM,OAAO;AAEb,QAAO,CACN,GAAG,KAAK,aAAa,QAAQ,2BAC7B,GAAG,KAAK,aAAa,QAAQ,mCAC7B"}
package/dist/package.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.3.1-pr.147.3d90e76";
2
+ var version = "2.3.1-pr.147.8743809";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.3.1-pr.147.3d90e76";
2
+ var version = "2.3.1-pr.147.8743809";
3
3
  //#endregion
4
4
  export { version };
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.3.1-pr.147.3d90e76",
3
+ "version": "2.3.1-pr.147.8743809",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "next",
@@ -1,8 +1,6 @@
1
- import { cookie as prismicCookie } from "@prismicio/client"
2
-
3
1
  import {
2
+ expiredDraftModeCookieHeaders,
4
3
  expiredPreviewCookieHeaders,
5
- expiredPreviewCookieSetOptions,
6
4
  } from "./lib/expiredPreviewCookies"
7
5
 
8
6
  /**
@@ -21,27 +19,15 @@ import {
21
19
  * ```
22
20
  */
23
21
  export async function exitPreview(): Promise<Response> {
24
- // Need this to avoid the following Next.js build-time error:
25
- // You're importing a component that needs next/headers. That only works
26
- // in a Server Component which is not supported in the pages/ directory.
27
- const { cookies, draftMode } = await import("next/headers")
28
-
29
- ;(await draftMode()).disable()
30
-
31
- // `redirectToPreviewURL` writes SameSite=None; Secure. The toolbar may
32
- // leave SameSite=Lax (not Secure). Those are different cookies to Chrome.
33
- // Expire both. Do not use `cookies().delete()`: on Next.js 13.4.5–15 it
34
- // omits Secure/SameSite. `cookies()` is name-keyed, so also emit both
35
- // Set-Cookie headers on the Response.
36
- const cookieJar = await cookies()
37
- for (const options of expiredPreviewCookieSetOptions) {
38
- cookieJar.set(prismicCookie.preview, "", options)
39
- }
40
-
22
+ // Do not call `cookies()` or `draftMode().disable()`. ResponseCookies is
23
+ // name-keyed: `appendMutableCookies` rebuilds Set-Cookie by name and drops
24
+ // the extra Lax expire. Emit every expire on the Response instead:
25
+ // toolbar Lax + iframe None; Secure for `io.prismic.preview`, and both
26
+ // shapes of `__prerender_bypass` that `disable()` would have cleared.
41
27
  const headers = new Headers({
42
28
  "Cache-Control": "no-store",
43
29
  })
44
- for (const setCookie of expiredPreviewCookieHeaders()) {
30
+ for (const setCookie of [...expiredPreviewCookieHeaders(), ...expiredDraftModeCookieHeaders()]) {
45
31
  headers.append("Set-Cookie", setCookie)
46
32
  }
47
33
 
@@ -42,10 +42,6 @@ export async function getPreviewRef(): Promise<string | undefined> {
42
42
  return
43
43
  }
44
44
 
45
- const isActiveCookie = cookie.includes("websitePreviewId=")
46
- if (!isActiveCookie) {
47
- return
48
- }
49
-
45
+ // Draft Mode gates preview reads; the Content API validates the opaque ref.
50
46
  return cookie
51
47
  }
@@ -2,36 +2,31 @@ import { cookie as prismicCookie } from "@prismicio/client"
2
2
 
3
3
  const epoch = new Date(0)
4
4
 
5
- /**
6
- * `cookies().set` options that expire both leftover shapes of `io.prismic.preview`: toolbar Lax
7
- * (not Secure) and the iframe write (SameSite=None; Secure).
8
- *
9
- * `cookies()` is name-keyed, so a Route Handler must also emit both `Set-Cookie` headers from
10
- * {@link expiredPreviewCookieHeaders}.
11
- */
12
- export const expiredPreviewCookieSetOptions = [
13
- {
14
- path: "/",
15
- sameSite: "lax",
16
- secure: false,
17
- httpOnly: false,
18
- expires: epoch,
19
- },
20
- {
21
- path: "/",
22
- sameSite: "none",
23
- secure: true,
24
- httpOnly: false,
25
- expires: epoch,
26
- },
27
- ] as const
5
+ function expiresAttr(): string {
6
+ return `Expires=${epoch.toUTCString()}`
7
+ }
28
8
 
29
9
  /** Expired `Set-Cookie` values for both leftover `io.prismic.preview` shapes. */
30
10
  export function expiredPreviewCookieHeaders(name = prismicCookie.preview): string[] {
31
- const expires = `Expires=${epoch.toUTCString()}`
11
+ const expires = expiresAttr()
32
12
 
33
13
  return [
34
14
  `${name}=; Path=/; ${expires}; SameSite=Lax`,
35
15
  `${name}=; Path=/; ${expires}; SameSite=None; Secure`,
36
16
  ]
37
17
  }
18
+
19
+ /**
20
+ * Expired `Set-Cookie` values for the App Router draft-mode cookie that `draftMode().disable()`
21
+ * would clear. Next sets `__prerender_bypass` as Lax (not Secure) in development and SameSite=None;
22
+ * Secure in production.
23
+ */
24
+ export function expiredDraftModeCookieHeaders(): string[] {
25
+ const expires = expiresAttr()
26
+ const name = "__prerender_bypass"
27
+
28
+ return [
29
+ `${name}=; Path=/; ${expires}; SameSite=Lax; HttpOnly`,
30
+ `${name}=; Path=/; ${expires}; SameSite=None; Secure; HttpOnly`,
31
+ ]
32
+ }