Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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 为什么用于角度开发的本地代理配置不起作用?_Javascript_Node.js_Angular_Typescript_Proxy - Fatal编程技术网

Javascript 为什么用于角度开发的本地代理配置不起作用?

Javascript 为什么用于角度开发的本地代理配置不起作用?,javascript,node.js,angular,typescript,proxy,Javascript,Node.js,Angular,Typescript,Proxy,我正在尝试用Angular开发一个应用程序。 我将package.json中的start命令设置为ngserve--proxyconfig proxyconfig.json,然后proxyconfig.json我进行了如下设置: { "/api": { "target": "http://localhost:1234", "secure": false, "changeOrigi

我正在尝试用Angular开发一个应用程序。 我将
package.json
中的start命令设置为
ngserve--proxyconfig proxyconfig.json
,然后
proxyconfig.json
我进行了如下设置:

{
  "/api": {
    "target": "http://localhost:1234",
    "secure": false,
    "changeOrigin": true
  },
  "/auth": {
    "target": "http://localhost:3000",
    "secure": false,
    "changeOrigin":  true
  }
}
但是,当我稍后尝试调用/api时

return this.http.get("/api/items.php").subscribe(...);
,我得到以下错误:

[HPM] Error occurred while trying to proxy request /api/items.php from localhost:4200 to http://localhost:1234 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
其中4200端口是Angular应用程序所在的位置。如果我转到
http://localhost:1234/items.php
直接使用,效果很好

不知道我做错了什么