summaryrefslogtreecommitdiff
path: root/extensions/fetch/26_fetch.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/fetch/26_fetch.js')
-rw-r--r--extensions/fetch/26_fetch.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/extensions/fetch/26_fetch.js b/extensions/fetch/26_fetch.js
index f7166001e..f6cfced14 100644
--- a/extensions/fetch/26_fetch.js
+++ b/extensions/fetch/26_fetch.js
@@ -40,6 +40,8 @@
TypeError,
Uint8Array,
} = window.__bootstrap.primordials;
+ const { getLocationHref } = window.__bootstrap.location;
+ const { URL } = window.__bootstrap.url;
const REQUEST_BODY_HEADER_NAMES = [
"content-encoding",
@@ -429,6 +431,17 @@
}
requestObject.signal[abortSignal.add](onabort);
+ const baseURL = getLocationHref();
+ if (
+ baseURL &&
+ (requestObject.method !== "GET" && requestObject.method !== "HEAD")
+ ) {
+ ArrayPrototypePush(request.headerList, [
+ "origin",
+ new URL(baseURL).origin,
+ ]);
+ }
+
if (!requestObject.headers.has("accept")) {
ArrayPrototypePush(request.headerList, ["accept", "*/*"]);
}