@sitecore-jss/sitecore-jss-nextjs 22.1.0-canary.60 → 22.1.0-canary.61
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.
|
@@ -227,6 +227,28 @@ class MetadataHandler {
|
|
|
227
227
|
path: query.route,
|
|
228
228
|
maxAge: 3,
|
|
229
229
|
});
|
|
230
|
+
// Cookies with the SameSite=Lax policy set by Next.js setPreviewData function causes CORS issue
|
|
231
|
+
// when Next.js preview mode is activated, resulting the page to render in normal mode instead.
|
|
232
|
+
// By replacing it with "SameSite=None; Secure", we ensure cookies are correctly sent with
|
|
233
|
+
// cross-origin requests, allowing the page to be editable. This change should be reverted
|
|
234
|
+
// once vercel addresses this open issue: https://github.com/vercel/next.js/issues/49927
|
|
235
|
+
const setCookieHeader = res.getHeader('Set-Cookie');
|
|
236
|
+
if (setCookieHeader && Array.isArray(setCookieHeader)) {
|
|
237
|
+
const modifiedCookies = setCookieHeader.map((cookie) => {
|
|
238
|
+
const cookieIdentifiers = {
|
|
239
|
+
__prerender_bypass: /^__prerender_bypass=/,
|
|
240
|
+
__next_preview_data: /^__next_preview_data=/,
|
|
241
|
+
};
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
243
|
+
for (const [_, regex] of Object.entries(cookieIdentifiers)) {
|
|
244
|
+
if (cookie.match(regex)) {
|
|
245
|
+
return cookie.replace(/SameSite=Lax/, 'SameSite=None; Secure');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return cookie;
|
|
249
|
+
});
|
|
250
|
+
res.setHeader('Set-Cookie', modifiedCookies);
|
|
251
|
+
}
|
|
230
252
|
const route = ((_c = (_b = this.config).resolvePageUrl) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
231
253
|
itemPath: query.route,
|
|
232
254
|
})) || query.route;
|
|
@@ -222,6 +222,28 @@ export class MetadataHandler {
|
|
|
222
222
|
path: query.route,
|
|
223
223
|
maxAge: 3,
|
|
224
224
|
});
|
|
225
|
+
// Cookies with the SameSite=Lax policy set by Next.js setPreviewData function causes CORS issue
|
|
226
|
+
// when Next.js preview mode is activated, resulting the page to render in normal mode instead.
|
|
227
|
+
// By replacing it with "SameSite=None; Secure", we ensure cookies are correctly sent with
|
|
228
|
+
// cross-origin requests, allowing the page to be editable. This change should be reverted
|
|
229
|
+
// once vercel addresses this open issue: https://github.com/vercel/next.js/issues/49927
|
|
230
|
+
const setCookieHeader = res.getHeader('Set-Cookie');
|
|
231
|
+
if (setCookieHeader && Array.isArray(setCookieHeader)) {
|
|
232
|
+
const modifiedCookies = setCookieHeader.map((cookie) => {
|
|
233
|
+
const cookieIdentifiers = {
|
|
234
|
+
__prerender_bypass: /^__prerender_bypass=/,
|
|
235
|
+
__next_preview_data: /^__next_preview_data=/,
|
|
236
|
+
};
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
238
|
+
for (const [_, regex] of Object.entries(cookieIdentifiers)) {
|
|
239
|
+
if (cookie.match(regex)) {
|
|
240
|
+
return cookie.replace(/SameSite=Lax/, 'SameSite=None; Secure');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return cookie;
|
|
244
|
+
});
|
|
245
|
+
res.setHeader('Set-Cookie', modifiedCookies);
|
|
246
|
+
}
|
|
225
247
|
const route = ((_c = (_b = this.config).resolvePageUrl) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
226
248
|
itemPath: query.route,
|
|
227
249
|
})) || query.route;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.1.0-canary.
|
|
3
|
+
"version": "22.1.0-canary.61",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"react-dom": "^18.2.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "^22.1.0-canary.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^22.1.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "^22.1.0-canary.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^22.1.0-canary.61",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^22.1.0-canary.61",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^22.1.0-canary.61",
|
|
78
78
|
"@vercel/kv": "^0.2.1",
|
|
79
79
|
"prop-types": "^15.8.1",
|
|
80
80
|
"regex-parser": "^2.2.11",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"description": "",
|
|
84
84
|
"types": "types/index.d.ts",
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "18e1922f358789f202797ef198794354ca2c0a03",
|
|
86
86
|
"files": [
|
|
87
87
|
"dist",
|
|
88
88
|
"types",
|