我不明白我错在哪里。
附:已经尝试通过这个答案修复但仍然不起作用
Angular-CLI 代理到后端不起作用 https://stackoverflow.com/questions/39809008/angular-cli-proxy-to-backend-doesnt-work
为后端请求中的自定义标头配置 Angular-cli 代理? https://stackoverflow.com/questions/44872498/configure-angular-cli-proxy-for-custom-headers-in-request-to-backend
Angular-CLI 代理不起作用 https://stackoverflow.com/questions/43616755/angular-cli-proxy-doesnt-work
ng serve --proxy-config proxy.config.json
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
10% building modules 3/3 modules 0 active[HPM] Proxy created: /api ->
http://localhost:1234
[HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
包.json
{
"name": "budget",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
代理配置.json
{
"/api": {
"target": "http://localhost:1234",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
角度 CLI:6.1.2
节点:10.8.0
操作系统:达尔文 x64
角度:6.1.1
npm -v 6.2.0