I built my backend using spring-boot and frontend using Angular cli when a get request is made to the server a method is executed which takes around 4-5 mins and the response is sent back to the client. Everything works well and fine when I hardcode the entire URL in httpclient get() method in service and run ng serve, request is sent and I get proper response but the moment I switch to proxy.config.json and run ng serve --proxy-config -proxy.conf.json , multiple requests are made to the server and eventually, I get an empty response I am unable to comprehend why it is happening? can anyone shed light on it?
This approach sends multiple requests:
fetchData(){
return this._http.get('info') }
Proxy config for the above approach
{
"/info":{
"target": "http://localhost:8080",
"secure": true
}
}
and this approach is not sending multiple requests
fetchData(){
return this._http.get(''http://localhost:8080/info'') }
I experimented with lite-server using bs-config file as well but the result is same. This behavior is only seen in development mode once the app is deployed it doesn't exhibit the same.continuation of this this issue was not reproduced after deployement.
I tried changing the proxy config.json using this link Proxy to Backend
My proxy config.json looks like this right now I added loglevel:debug
to know what is happening
{
"/info": {
"target": {
"host": "localhost",
"protocol": "http:",
"port": 8080
},
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
Here is the Output Log on console It can be seen that there are two requests to the backend, I invoked the get request once, internally two requests are sent. Here is the Error in chrome's console Response & Chrome's network tab Trying hard to figure out why this is happening?