-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch16.mjs
More file actions
30 lines (24 loc) · 1.12 KB
/
patch16.mjs
File metadata and controls
30 lines (24 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import fs from 'fs';
let content = fs.readFileSync('Cloudflare_Workers/worker.mjs', 'utf8');
// handleSecurityProxy is completely missing but is being called on line 519.
// I will just implement a simple handleSecurityProxy function that fetches from the main website.
const securityProxyCode = `
export async function handleSecurityProxy(pathname, env, corsHeaders) {
try {
const response = await fetch(\`https://brackenw3.github.io\${pathname}\`);
if (!response.ok) return new Response("Not Found", { status: 404, headers: corsHeaders });
const text = await response.text();
const headers = new Headers(corsHeaders);
headers.set("Content-Type", "text/plain");
headers.set("Cache-Control", "public, max-age=86400");
return new Response(text, { status: 200, headers });
} catch (error) {
return new Response("Error fetching security policy", { status: 500, headers: corsHeaders });
}
}
`;
content = content.replace(
`export async function handleGitHubGraphQL`,
securityProxyCode + `\nexport async function handleGitHubGraphQL`
);
fs.writeFileSync('Cloudflare_Workers/worker.mjs', content, 'utf8');