ng serve — proxy-config proxy.conf.json 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
export const environment = {
production: false,
apiUrl: 'http://my-api-url'
};