Skip to content

Commit 3161383

Browse files
committed
Remove specific headers for cloudflare to have better cache regularity
1 parent 783d5b4 commit 3161383

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

worker/worker.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ function create_redirectionio_request(request, libredirectionio) {
4242
const redirectionioRequest = new libredirectionio.Request(urlObject.pathname + urlObject.search, urlObject.host, urlObject.protocol.includes('https') ? 'https' : 'http', request.method);
4343

4444
for (const pair of request.headers.entries()) {
45+
// remove cloudflare specific headers
46+
if (pair[0] === "cf-request-id") {
47+
continue;
48+
}
49+
50+
if (pair[0] === "cf-ray") {
51+
continue;
52+
}
53+
54+
if (pair[0] === "cf-visitor") {
55+
continue;
56+
}
57+
4558
redirectionioRequest.add_header(pair[0], pair[1]);
4659
}
4760

@@ -55,7 +68,7 @@ async function get_action(request, redirectionioRequest, options, libredirection
5568

5669
// Convert to a GET to be able to cache
5770
const cacheKey = new Request(cacheUrl.toString(), {
58-
headers: request.headers,
71+
headers: [],
5972
method: "GET",
6073
});
6174

0 commit comments

Comments
 (0)