我有两台服务器。一台是我的 api 服务器
,另一台是我的渲染服务器
。两者都在 Node.js 中。当我使用 axios 从渲染服务器调用任何 api 到我的 api 服务器并在我的 api 服务器中获取 req.headers['user-agent']
时,它只给我 axios/0.15 .2
。但我想要完整的用户代理信息,如浏览器、操作系统、设备等。如何获取这些信息?
最佳答案
设置自定义 header ,例如:
var config = {
headers: {'X-My-Custom-Header': 'Header-Value'}
};
axios.get('https://api.github.com/users/codeheaven-io', config);
axios.post('/save', { firstName: 'Marlon' }, config);
关于node.js - 从 Node js 中的 axios 调用调用时,用户代理信息不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41607257/