Cookie Samesite 问题
- developers.google.com/search/blog...
- www.chromium.org/updates/sam...
- github.com/GoogleChrom...
- releases.electronjs.org/releases/st...
Chrome 94 版本不再放行,无法再携带 Cookies,也就是 Electron v14 之后的版本无法通过 webSecurity: false
来禁用这些问题。
新版本(v27),通过复写 onHeadersReceived
实现。
js
function disableSamesiteCookies(filter = ["*://*/*"]) {
session.defaultSession.webRequest.onHeadersReceived(
{ urls: filter },
(details, callback) => {
const newCookies = [];
details?.responseHeaders?.["set-cookie"]?.map((item) =>
newCookies.push(item.split("; ")[0] + "; Secure; SameSite=None")
);
details.responseHeaders["set-cookie"] = newCookies;
callback({ cancel: false, responseHeaders: details.responseHeaders });
}
);
}
Github github.com/lecepin/Deb...