forked from Reamd7/notion-zh_CN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookie.js
27 lines (24 loc) · 994 Bytes
/
cookie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(async function main() {
await cookieStore.delete("NEXT_LOCALE");
await cookieStore.delete("notion_locale");
await cookieStore.set("NEXT_LOCALE", "zh-CN");
await cookieStore.delete("notion_locale", "zh-CN/autodetect");
console.log(cookieStore.getAll().then(console.log));
cookieStore.addEventListener("change", async (event) => {
await cookieStore.delete("NEXT_LOCALE");
await cookieStore.delete("notion_locale");
await cookieStore.set({
name: "NEXT_LOCALE",
value: "zh-CN",
});
await cookieStore.delete("notion_locale", "zh-CN/autodetect");
});
})()
let headers = $request.headers;
let cookies = headers.cookie;
const locale = "NEXT_LOCALE:zh-CN; notion_locale:zh-CN/autodetect;"
if (cookies) {
$request.headers.cookie = cookie.split(";").filter(value => !(value.includes("NEXT_LOCALE") || value.includes("notion_locale"))).join(";") + locale
} else {
$request.headers.cookie = locale;
}