当我发布请求时,我显式设置了标题字段Connection: Keep-Alive
。
const res = await fetch("/enddev", {
method: "POST",
headers: {
"Content-Type": "application/json",
Connection: "Keep-Alive"
},
body: '{"id": "FFAABBCC"}'
});
在Node.js服务器上,我打印出请求标头以进行调试:
app.post("/enddev", (req, res) => {
console.log("REQUEST TO ", req.route.path);
console.log("Req Header ", req.headers);
socket = res.socket;
res.send("request\r\n");
});
这是根据要求提供的Heroku控制台: