Reputation: 175
Application makes an api call when I ask for customer data. For one customer it works but for another same api call exactly the same way done using the same proxy below fails.
Realised that in that instance the JSON response have error attached at the end of it (concatenated at the end of array in json file) so gives an JSON error. But the same call for another customer doesn't do that.
Added proxy.config.json in project root directory
{
"/api/*": {
"target": "http://<server_ip_address>:<port>",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
Then added the proxy config in start in package.json
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --extract-css=true",
"build": "ng build --prod --aot=false --output-path dist",
"test": "jest",
"codecoverage": "jest --coverage",
"test:watch": "jest --watch",
"lint": "ng lint",
"e2e": "ng e2e"
},
ERROR:
[HPM] Error occurred while trying to proxy request /api/v1/login from localhost:4200 to http://: (ECONNRESET) (https ://nodejs.org/api/errors.html#errors_common_system_errors)
If I check the chrome network console, the status of request is OK. But in the preview tab, it shows JSON from server and then it appends with following string
Error occurred while trying to proxy request /api/getList?offset=0&limit=50 from localhost:4200 to http://localhost:8080
Awkwardness!!
The same code base does not give error in Linux machines. I have Mac OS. Also same api does not give error on gettingList for other customers.
There is a similar question but all the answers do not solve the problem. I have tried all of the ones that are appropriate.
Upvotes: 0
Views: 801
Reputation: 175
I was too desperate that I created another question on this matter and now I have answer.
Added
"headers": {
"Connection": "keep-alive"
}
option to the api value object on proxy.config.json and now I am getting no errors. including the data loads and I can run PUT calls with no problem.
Upvotes: 0