当我将环境api url更改为与angular app(4200)不同时,我无法使代理工作。因此,如果我从http://localhost:4200/api
更改为http://localhost:8090/api
,它就会停止工作:(
我像这样运行我的应用
ng serve --proxy-config proxy.conf.json
proxy.conf.json
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug"
}
}
environment.ts
export const environment = {
production: false,
apiUrl: "http://localhost:8090/api"
};
调试输出
** Angular Live Development Server is listening on localhost: 4200, open your browser on http://localhost:4200/ **
[HPM] Proxy created: /api -> http://localhost:3000
[HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
所以回顾一下。如果我将apiUrl
更改为http://localhost:4200/api
则可行。但不是我所展示的。
我做错了什么?