如何在angularcli项目的proxy.config.json文件中设置代理标头 [英] How set proxy headers in proxy.config.json file for angularcli project
问题描述
我正在尝试为angularcli
设置代理标头.这是到目前为止我的proxy.config.json
文件中的内容:
I'm trying to set proxy headers for angularcli
. Here's what I have so far in my proxy.config.json
file:
"/api": {
"target": "https://applications.str.coni.com/api",
"secure": false,
"logLevel": "debug"
但是到目前为止,我还没有运气,也许我缺少了一些东西(可能在另一个文件中).任何建议将不胜感激.
But I haven't had any luck so far, perhaps I'm missing something (probably in another file). Any suggestions would be much appreciated.
推荐答案
Angular-cli使用http-proxy-middleware
https://github.com/chimurai/http-proxy-middleware
Angular-cli uses http-proxy-middleware
https://github.com/chimurai/http-proxy-middleware
有一个名为headers
的选项可以使用: https ://github.com/chimurai/http-proxy-middleware#http-proxy-option
there is an option called headers
that you can use: https://github.com/chimurai/http-proxy-middleware#http-proxy-option
示例:
"/api":
{
"target": "https://applications.str.coni.com/api",
"secure": false,
"logLevel": "debug",
"headers": {"host":"www.example.org"}
}
这篇关于如何在angularcli项目的proxy.config.json文件中设置代理标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!