我在 Cloudflare 中有一个域A.tk
,并且我的服务器无法将端口 80 与 domain 一起使用A.top
。访问的唯一方法A.top
是A.top:61445
,所以我尝试fetch('A.top:61445')
在 Cloudflare worker 中,并在访问时更改响应A.tk
。worker 一切正常,浏览器不行,问题在哪里
async function handleRequest(request) {
if(request.url.toString().indexOf('learn')!=-1)
{
let path = request.url.replace('.tk/', '.top:61445/')
path = path[-1]=='/'?path:path+'/'
let real = fetch(path)
console.log(real.url) //why is undefined
return real
}
else
{
let path = request.url.replace('.tk/', '.top/')
return fetch(path)
}
}
addEventListener('fetch', async event => {
event.respondWith(handleRequest(event.request))
})