2
我通过我的快递配置以下设置进行代理我的API添加自定义标题为“请求”
// Proxy api calls
app.use('/api', function (req, res) {
let url = config.API_HOST + req.url
req.pipe(request(url)).pipe(res)
})
在这里config.API_HOST
解决了我的API URL和req.url
一些端点即/users
我试过以下的NPM文件为request,并设置了我的头,像这样
// Proxy api calls
app.use('/api', function (req, res) {
let options = {
url: config.API_HOST + req.url,
options: { 'mycustomheader': 'test' }
}
req.pipe(request(options)).pipe(res)
})
但我无法看到网络下的Chrome浏览器开发工具,我的自定义标题。