async function handleRequest(request) {
// 发送原始请求并获取原始结果
let originalResponse = await fetch(request);
// 修改body
let body = JSON.stringify({ foo: 'bar'});
response = new Response(body, originalResponse);
// 修改headers
response.headers.set('foo', 'bar');
return response;
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
修改返回
暂无讨论,说说你的看法吧