Skip to content

Instantly share code, notes, and snippets.

@symant233
Created August 22, 2021 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symant233/bac4df4514dff297dd06a6fc47f92d9f to your computer and use it in GitHub Desktop.
Save symant233/bac4df4514dff297dd06a6fc47f92d9f to your computer and use it in GitHub Desktop.
Raw content http proxy for cloudflare workers (GET only). try `https://${ID}.${yourName}.workers.dev/?https://${uri}`
addEventListener("fetch", (event) => {
const res = handleRequest(event.request)
.catch((err) => new Response(err.stack, { status: 500 }))
event.respondWith(res);
});
/**
* @param {FetchEvent} request
*/
async function handleRequest(request) {
const path = request.url;
const index = path.indexOf('dev/?');
if (index) {
let res = await fetch(path.slice(index + 5));
return res;
}
return new Response(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment