Created
June 29, 2024 03:50
-
-
Save gacfox/1b1e93ecd1a99ac988b4831c6e9fb724 to your computer and use it in GitHub Desktop.
Cloudflare worker for reverse proxying gitee image repository
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
| const accessToken = ''; | |
| const owner = ''; | |
| const repo = ''; | |
| const ref = 'master'; | |
| export default { | |
| async fetch(request, env, ctx) { | |
| const url = new URL(request.url); | |
| const path = url.pathname; | |
| const req = `https://gitee.com/api/v5/repos/${owner}/${repo}/raw/${path}?access_token=${accessToken}&ref=${ref}`; | |
| let response = await fetch(req, { | |
| headers: { | |
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', | |
| }, | |
| }); | |
| return new Response(response.body, { | |
| status: response.status, | |
| body: response.body, | |
| headers: response.headers, | |
| }); | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment