rewrite Referer header

This commit is contained in:
velzie 2024-07-19 13:52:48 -04:00
parent 80d51ed7a7
commit 0472b7fc1e
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F

View file

@ -24,10 +24,17 @@ export async function swfetch(
try { try {
const url = new URL(decodeUrl(request.url)); const url = new URL(decodeUrl(request.url));
let headers = new Headers();
for (const [key, value] of request.headers.entries()) {
headers.set(key, value);
}
headers.set("Referer", decodeUrl(request.referrer));
const response: BareResponseFetch = await this.client.fetch(url, { const response: BareResponseFetch = await this.client.fetch(url, {
method: request.method, method: request.method,
body: request.body, body: request.body,
headers: request.headers, headers,
credentials: "omit", credentials: "omit",
mode: request.mode === "cors" ? request.mode : "same-origin", mode: request.mode === "cors" ? request.mode : "same-origin",
cache: request.cache, cache: request.cache,