[英]Angular-CLI proxy to path
I am trying to configure my local angular cli instance to proxy my requests to a specific path.我正在尝试配置我的本地 angular cli 实例以将我的请求代理到特定路径。 Examples on the internet show only proxying to a domain.
Internet 上的示例仅显示代理到域。 The documentation on proxying didn't help me much either.
有关代理的文档也对我没有太大帮助。 What I am trying is:
我正在尝试的是:
{
"/portal/*": {
"target": "http://my.host/portal/",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
I want all requests made to /portal/
to go to http://my.host/portal/
like portal/api/v1/customer/13
to my.host/portal/api/v1/customer/13
我希望向
/portal/
发出的所有请求都转到http://my.host/portal/
像portal/api/v1/customer/13
到my.host/portal/api/v1/customer/13
When you are using proxy, set target
to your domain ONLY.当您使用代理时,仅将
target
设置为您的域。 Your angular-cli makes request to my.host/portal/portal/api/v1/customer/13
您的 angular-cli 向
my.host/portal/portal/api/v1/customer/13
提出请求
Change your json to following (delete context root from target domain)将您的 json 更改为以下(从目标域中删除上下文根)
{
"/portal/*": {
"target": "http://my.host",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.