merge upstream

This commit is contained in:
2025-03-05 09:52:29 +08:00
3 changed files with 12 additions and 26 deletions

View File

@@ -1,25 +0,0 @@
name: Deploy to Cloudflare Workers(Staging)
on:
pull_request_target:
paths-ignore:
- '**.md'
repository_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
name: Build & Deploy
steps:
- uses: actions/checkout@v4
- name: Publish
uses: cloudflare/wrangler-action@v3
env:
CUSTOM_DOMAIN: ${{ secrets.CUSTOM_DOMAIN || 'libcuda.so' }}
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{secrets.CF_ACCOUNT_ID}}
vars:
CUSTOM_DOMAIN
command: deploy --env staging --minify src/index.js
environment: staging

View File

@@ -105,12 +105,22 @@ async function handleRequest(request) {
const newReq = new Request(newUrl, { const newReq = new Request(newUrl, {
method: request.method, method: request.method,
headers: request.headers, headers: request.headers,
redirect: "follow", // don't follow redirect to dockerhub blob upstream
redirect: isDockerHub ? "manual" : "follow",
}); });
const resp = await fetch(newReq); const resp = await fetch(newReq);
if (resp.status == 401) { if (resp.status == 401) {
return responseUnauthorized(url); return responseUnauthorized(url);
} }
// handle dockerhub blob redirect manually
if (isDockerHub && resp.status == 307) {
const location = new URL(resp.headers.get("Location"));
const redirectResp = await fetch(location.toString(), {
method: "GET",
redirect: "follow",
});
return redirectResp;
}
return resp; return resp;
} }

View File

@@ -12,6 +12,7 @@ CUSTOM_DOMAIN = "lolicon.in"
[env.dev.vars] [env.dev.vars]
MODE = "debug" MODE = "debug"
TARGET_UPSTREAM = "https://registry-1.docker.io" TARGET_UPSTREAM = "https://registry-1.docker.io"
CUSTOM_DOMAIN = "exmaple.com"
[env.production] [env.production]
name = "cloudflare-docker-proxy" name = "cloudflare-docker-proxy"