教程

Github



获取Token



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

CloudFlare

新建worker

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  const url = new URL(request.url)
  const path = url.pathname
  
  // 定义环境变量 GITHUB_USERNAME 和 GITHUB_PAT
  const GITHUB_USERNAME = 'zbb7001' // 替换为你的 GitHub 用户名
  const GITHUB_PAT = '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' // 替换为你的 GitHub PAT,只开放 repo 权限即可
  
  // 构建 GitHub raw 内容的 URL
  const githubUrl = `https://raw.githubusercontent.com/${GITHUB_USERNAME}${path}`
  
  // 创建新的请求,添加必要的头部
  const modifiedRequest = new Request(githubUrl, {
    method: request.method,
    headers: {
      ...request.headers,
      'Authorization': `token ${GITHUB_PAT}`,
      'Accept': 'application/vnd.github.v3.raw'
    }
  })
  
  // 发送请求并返回响应
  try {
    const response = await fetch(modifiedRequest)
    
    // 如果响应不成功,抛出错误
    if (!response.ok) {
      throw new Error(`GitHub API responded with ${response.status}: ${response.statusText}`)
    }
    
    // 创建新的响应,保留原始内容但移除敏感头部
    const newResponse = new Response(response.body, response)
    newResponse.headers.delete('Authorization')
    
    return newResponse
  } catch (error) {
    return new Response(`Error: ${error.message}`, { status: 500 })
  }
}

注意:如有问题看一下是否为main


img7/main/README.md 测试



https://tt.y07.dpdns.org/

PicGo

插件设置



scHQZ2CmlQDdRJnMQ9SjXKVfByCwY3YD

PicGo设置


图床设置 GitHub



图床配置名             img7
设定仓库名             zbb7001/img7
设定分支名             main
设定Token              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
设定存储路径          ku/
设定自定义域名       https://tt.y07.dpdns.org/img7/main 

上传



重要

后期如果上传失败,则需更新Token,共需修改2处。



转载请注明出处