proxy.json code example
Example 1: angular run with proxy
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": { "^/api": "" } // needed if you want to change api to empty when calling your backend service
}
}
ng serve --proxy-config proxy.conf.json
Example 2: package json proxy
"proxy": "http://localhost:4000"
Example 3: adding prod environment file in angular8
content_copy
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"pathRewrite": {
"^/api": ""
}
}
}