set proxy for angular using config code example
Example 1: angular run with proxy
# Create Proxy file proxy.conf.json in root folder with the below content
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": { "^/api": "" }
}
}
# when you run use
ng serve --proxy-config proxy.conf.json
Example 2: adding prod environment file in angular8
content_copy
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"pathRewrite": {
"^/api": ""
}
}
}