Skip to content

Instantly share code, notes, and snippets.

@symant233
Created August 22, 2021 14:50
Embed
What would you like to do?
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