Skip to content

Instantly share code, notes, and snippets.

@gacfox
Created June 29, 2024 03:50
Show Gist options
  • Select an option

  • Save gacfox/1b1e93ecd1a99ac988b4831c6e9fb724 to your computer and use it in GitHub Desktop.

Select an option

Save gacfox/1b1e93ecd1a99ac988b4831c6e9fb724 to your computer and use it in GitHub Desktop.
Cloudflare worker for reverse proxying gitee image repository
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