I want to show popup with url when for example firewall is blocking any of them from my backend. I should get 403 status response, but all the time Im getting status 0.
I see similar topic here but I dont know whether should I use it:
Angular http returning status 0, but I expect 404
is that a good point with that solution? If yes then how or where should I use it?
In my service there should be only error.status == 403 but I cannot figure out how to get real status and not 0.
I dont think that CORS is the problem because if firewall block my request then It will never hit the backend. Am I right?
this.httpClient.request(request).toPromise()
.then(
(res: any) => { // Success
resolve(res.body);
},
(error: any) => { // Error
if (error.status == 403){
this.respondedWithError$.emit(error.url);
}
if (error.status == 0){
this.respondedWithError$.emit(error.error.currentTarget.__zone_symbol__xhrURL);
}
reject(error.error);
}
);
Current result:
message: "Http failure response for (unknown url): 0 Unknown Error"
name: "HttpErrorResponse"
status: 0
statusText: "Unknown Error"
Expected result:
status: 403