对 Node Express API 的 Powerpoint 超链接 GET 请求启动 3 个调用

Powerpoint hyperlink GET request to Node Express API launches 3 calls

我有一个 node.js express REST API 运行 在控制器的 GET 端点中有一些逻辑。

当我在浏览器中输入 url 时,一切看起来都很好。只有一个请求和逻辑 运行 一次:

获取 /api/users/ppt/confirm 200 77 毫秒

消息已发送:250 2.0.0 正常:排队为 3n5vdG0v13zghfL

出于 prototyping/meeting 目的,我需要 运行 来自 powerpoint 超链接的请求。结果是,当我从 ppt 按钮单击超链接时,我的服务器 运行 控制器 3 次:

头部/api/users/ppt/confirm 200 7ms

获取 /api/users/ppt/confirm 200 6ms

获取 /api/users/ppt/confirm 200 6ms

消息已发送:250 2.0.0 正常:排队为 3n5vnz477wzghfL

消息已发送:250 2.0.0 正常:排队为 3n5vnz67mpzghfN

消息已发送:250 2.0.0 正常:排队为 3n5vp03JsKzghfR

HEAD 那个让我怀疑,但我真的不知道发生了什么。

我该如何解决?

谢谢。

我用控制器内部的 if 语句解决了这个问题:

/*You can use any other request-headers based condition but this one works
 for me */

if(req.headers['user-agent'].split(' ')[0] == "Mozilla/5.0"){

  //do stuff
}
else{
  res.writeHeader(200, {"Content-Type": "text/html"});  
  res.write("Hi PowerPoint");  
  res.end(); 
  return;
}