Created
September 18, 2025 08:05
-
-
Save ircfspace/e3fab304e4db6ea76eb94ee6e230997c to your computer and use it in GitHub Desktop.
Simple GitHub Raw Proxy Worker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
async fetch(request) { | |
const url = new URL(request.url); | |
const path = url.pathname.replace(/^\/+/, ""); | |
const parts = path.split("/"); | |
if (parts.length < 4) { | |
return new Response("Usage: /owner/repo/branch/path/to/file.ext", { status: 400 }); | |
} | |
const [owner, repo, branch, ...filePathParts] = parts; | |
const filePath = filePathParts.join("/"); | |
const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${filePath}`; | |
const resp = await fetch(rawUrl); | |
return new Response(resp.body, { | |
status: resp.status, | |
headers: resp.headers, | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
دمت گرم