主要问题:
如果它是由公共代理服务器创建的,我是否需要在每个内部微服务请求中传递标头才能将其包含在其他微服务中?
示例:
Structure:个
在Nginx.conf:proxy_set_header X-Request-ID $request_id;
当我请求这些微服务中的任何一个时,我可以使用req.headers["x-request-id"]
来获取标头值
但是,当我真的喜欢:
// calling ms2 from ms1
const response = await fetch("http://ms2/");
在ms1米(第一跳),我可以像我之前展示的那样获得头球,但在ms2米我不能.
我知道Express服务器同时处理大量请求,这就是它的原因.但无论如何,当您每次都需要传递内部请求的头时,感觉很奇怪:
// calling ms2 from ms1
const response = await fetch("http://ms2/", {
headers: {
"X-Request-ID": req.headers["x-request-id"],
},
});
// when do like this I can get the value in ms2.
有没有办法,或者说它就是这样?