Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  6] [ 6]  / answers: 1 / hits: 15391  / 6 Years ago, thu, july 19, 2018, 12:00:00

I am getting a problem with possibly Cors. I am doing local dev(react frontend, asp.net core 2 api backend).



Both IE 11 and Chrome have no problem, but Firefox has a problem with my requests.



I just keep getting Network Error from my calls.



I disabled HSTS in firefox and now I am seeing a warning message



Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:44391/api/tokens/auth. (Reason: CORS request did not succeed).


In my cor right now to make dev simple I just have



public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
...
}




public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors(builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
}

More From » ssl

 Answers
10

I had the same issue, but it turned out that the CORS error was a bit of a red herring. I opened the Developer Console in Firefox, clicked on the Options request under Network and then went to the security tab. I saw the following:



An error occurred mozilla_pkix_error_self_signed_cert



I fixed this by going to the Properties for my .Net Core app in Visual Studio. I selected Debug from the menu on the left hand side. There was a checkbox on the page called Enable SSL along with a URL (https://localhost:44358/ in my case). I browsed to this page in Firefox, got a warning page, added a security exception for it and everything worked as expected after that.



If you don't see the warning page clear your cache as per the suggestions here: Certificate Issue


[#53933] Tuesday, July 17, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;