Skip to content

Commit fde8718

Browse files
committed
feat: persist ncr value across navigation
1 parent 9af76d9 commit fde8718

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/server.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,17 @@ export function createApp(siteId: string) {
329329
const blobPrefix = `/${BUCKET}/fileset/sites/${manifest.site}/blobs`;
330330
let is404Page = req.path === defaults.DEFAULT_404_PAGE;
331331

332+
// Set a cookie indicating that the user wants to disable localization redirects.
333+
if ('ncr' in req.query) {
334+
res.cookie('ncr', 'true', {
335+
httpOnly: true,
336+
secure: true,
337+
});
338+
}
339+
332340
// If a localized URL path was found, and if `?ncr` is not present, redirect.
333-
if (localizedUrlPath && req.query.ncr === undefined) {
341+
const ncr = 'ncr' in req.query || req.cookies.has('ncr');
342+
if (localizedUrlPath && !ncr) {
334343
if (localizedUrlPath.endsWith('/index.html')) {
335344
localizedUrlPath = localizedUrlPath.slice(0, -10);
336345
}

0 commit comments

Comments
 (0)