{
"/api/": {
"target": "http://******/api/",
"changeOrigin": true,
"secure": false,
"pathRewrite": {
"^/api": ""
}
}
}
根目录添加 proxy.config.json,如果遇到404的情况,记得加上 "changeOrigin": true, 就可以了
package.json 中添加,然后运行 npm start
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},