问题
I have a angular 5 application which calls a .NET Core 2.0 backend api. Call to the API from the angular service works fine in all browsers (Chrome, Firefox, IE11) but not in EDGE. In EDGE, i am getting the error
Http failure response for (unknown url): 0 Unknown Error.
It is a CROSS ORIGIN CALL and Cors has been enabled in the API as below. Right now i am enabling for any origin
services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins",
builder =>
{
builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
});
});
And in Configure method
app.UseCors("AllowAllOrigins");
It works for all browsers except Edge. Appreciate your help.
回答1:
Got into the same situation - Angular 6, Edge, same error, other browsers worked fine. Using Fiddler worked as a workaround.
Problem was, that my web was running on localhost and Edge enforced different security rules. Once I've tested the web site on different server, it worked like a charm.
Suppose it might be related to this question.
回答2:
Http failure response for (unknown url): 0 Unknown Error.
This error occure due to edge have advanced security as compared to other browser. this is actully Cors issue .
that can be solved in two way->
either you can modify header in server side by adding as Access-Control-Allow-Origin:* or
configure the proxy.conf.json inside the angular make sure when you configured the proxy then its won't show the actual server url in broswer console,
for example , your client url as localhost:3000 and server url where api hosted as www.server.com/api/apiname then in browser console it will show like below
localhost:3000/api/apiname
来源:https://stackoverflow.com/questions/50166277/angular-5-http-failure-response-for-unknown-url-0-unknown-error-in-edge-brow