Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法为angular代理对后端api的调用_Javascript_Angular_Angular Cli_Angular Httpclient_Angular Cli V6 - Fatal编程技术网

Javascript 无法为angular代理对后端api的调用

Javascript 无法为angular代理对后端api的调用,javascript,angular,angular-cli,angular-httpclient,angular-cli-v6,Javascript,Angular,Angular Cli,Angular Httpclient,Angular Cli V6,我遵循使用angular CLI将代理配置到后端的指南 我使用的角度版本:6 我的proxy-conf.json的详细信息 { "/backend": { "target": "https://application-inCloud.predix.io", "secure": false, "logLevel": "info", "timeout":10000 , "changeOrigin": "true", "headers": {"Au

我遵循使用angular CLI将代理配置到后端的指南

我使用的角度版本:6

我的proxy-conf.json的详细信息

{
  "/backend": {
    "target": "https://application-inCloud.predix.io",
    "secure": false,
    "logLevel": "info",
    "timeout":10000 ,
    "changeOrigin": "true",
    "headers": {"Authorization":"Bearer token",
    "header2": "123"}
  }
}
我如何在服务中调用api的详细信息 使用HTTPCLIENT

    const url = "/backend/getSomething"
    const headers = new HttpHeaders({"Authorization":"Bearer token",
            "header2": "123"});
   return this.http.get(url, {headers: headers});
我犯了一个错误

[HPM] Error occurred while trying to proxy request https://application-inCloud.predix.io from localhost:4200 to https://application-inCloud.predix.io (ENOTFOUND) (https://nodejs.org/api/errors.html#errors_common_system_errors)
我做错了什么

当我尝试在《邮递员》中使用API时,它工作得很好。
我无法控制API,如果没有代理,angular会发出飞行前请求,最终403失败,因此对于开发人员,我考虑使用代理选项

看起来像
https://application-inCloud.predix.io
不存在。我无法发布实际的API,但这只是为了描述它是云中的一个RESTAPI。也许可以尝试将它与
ip
一起使用,而不是与servername一起使用。