示例代码
async function handleRequest(request) {
// 获取网络资源
const url = "https://www.ctyun.cn"
const response = await fetch(url);
return response;
}
addEventListener('fetch', event => {
return event.respondWith(handleRequest(event.request));
});
示例预览
在浏览器地址栏中输入匹配到HTTP路由的URL,即可预览示例效果。