@
xingchenxf @
vueli const main = async function (request: Request): Promise<Response> {
// 获取客户端传入的数据
// 需要跟进请求类型与 ContentType 来做处理
const body = await request.arrayBuffer();
// 代理请求
const res = await fetch(request.url, {
body: body,
method: request.method,
// 如果要隐藏客户端 IP, 需重新构造 Headers
headers: new Headers(request.headers),
});
const status = res.status;
const statusText = res.statusText;
const value = await res.arrayBuffer();
return new Response(value, {
status,
statusText,
headers: res.headers,
});
}