涉及的相关的网址和代码:
https://github.com/XIU2/CloudflareSpeedTest/issues/168
addEventListener("fetch", event => {
let url = new URL(event.request.url);
if (url.pathname == "/" && url.search == "") {
url.href=""
let request = new Request(url, event.request);
event.respondWith(fetch(request));
}
})
视频演示: