Skip to content

Commit

Permalink
🐛 默认不传origin header #233
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Sep 14, 2023
1 parent 5eb7c5a commit 9d4ebcc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/runtime/background/utils.ts
Expand Up @@ -270,8 +270,12 @@ export function setXhrHeader(
) {
xhr.setRequestHeader(`${headerFlag}-gm-xhr`, "true");
if (config.headers) {
let hasOrigin = false;
Object.keys(config.headers).forEach((key) => {
const lowKey = key.toLowerCase();
if (lowKey === "origin") {
hasOrigin = true;
}
if (
unsafeHeaders[lowKey] ||
lowKey.startsWith("sec-") ||
Expand All @@ -292,6 +296,9 @@ export function setXhrHeader(
xhr.setRequestHeader(key, config.headers![key]!);
}
});
if (!hasOrigin) {
xhr.setRequestHeader(`${headerFlag}-origin`, "");
}
}
if (config.maxRedirects !== undefined) {
xhr.setRequestHeader(
Expand Down

0 comments on commit 9d4ebcc

Please sign in to comment.