My development environment angular server runs on localhost:4200 and spring boot server runs on localhost:8080. Angular service invokes rest api calls using
this.http.get(window.location.protocol + '//' + window.location.hostname + ':8080/' +'<context-path>/api/<endpoint>');
Proxy configuration file:
{
"/api": {
"target": "http://localhost:800/",
"secure": false,
"logLevel": "debug",
"changeOrigin": false
}
}
I am starting my server using
ng serve --proxy-config proxy.conf.json
Intentionally I provided port number as 800, Still I can get results from server. This made sure for me that proxy configuration file is not being read.
When we can directly access the url from angular service, why do we need proxy configuration file?