const proxyOrigin = 'https://www.myflv.cn'
const proxyUrl = new URL(proxyOrigin)
const proxyHost = proxyUrl.host
export default {
async fetch(request, env, ctx) {
const requestUrl = new URL(request.url)
const requestOrigin = requestUrl.origin
const proxyUrl = request.url.replace(requestOrigin, proxyOrigin)
const proxyHeaders = new Headers(request.headers)
proxyHeaders.set('host', proxyHost)
const proxyRequest = new Request(proxyUrl, {
method: request.method,
headers: proxyHeaders,
body: request.body,
redirect: 'manual'
})
return await fetch(proxyRequest)
}
}
cf worker请求转发
评论 (暂无评论)