title: Angular + NET Core "Http failure response for (unknown url): 0 Unknown Error"
body: <p>I am trying to send a GET request from my angular app to my .NET Core WebAPI backend. Both are running on localhost. Angular is running on port 4200, WebAPI is running on port 5001. When I make the GET request in Angular, the following error is shown in console:</p>
  
  <p><a href="https://i.stack.imgur.com/avC6X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/avC6X.png" alt="Console error"></a></p>
  
  <p>After searching online, almost every answer comes down to an issue with CORS not being enabled correctly on the backend server. However, to my knowledge, I have CORS setup correctly. Here is my configuration for CORS:</p>
  
  <p><a href="https://i.stack.imgur.com/MpeUK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MpeUK.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/1UFr3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1UFr3.png" alt="enter image description here"></a></p>
  
  <p>This is the service function in Angular as well as the GET method in WebAPI:</p>
  
  <p><a href="https://i.stack.imgur.com/MRWQv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MRWQv.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/1tor9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1tor9.png" alt="enter image description here"></a></p>
  
  <p>I know the URL is correct, because, when I copy the URL into Postman, it works as intended.</p>
  
  <p>Mainly I'm wondering if I did mess up CORS, because that seems to be the main issue with this error message, or if there is something else I may have missed.</p>
  
  <p><strong>EDIT (Solution)</strong>:
  Ok, so through various trials and errors, I believe I have found the issue. When I made the initial project, I made the project in JetBrains Rider. I decided to try making a new project in Visual Studio to see what would happen, however, the problem still remained. As it turns out the issue was not with CORS, but with an invalid HTTPS localhost certificate. When I tried to run the console command <code>dotnet dev-certs https --trust</code> I did not get a popup to confirm the certificate, but instead just a generic error message that was not useful. Here is how I fixed the issue (whether or not this is the right way can be for discussion).</p>
  
  <ol>
  <li>Ran the WebAPI and opened the site in Chrome.</li>
  <li>On HTTPS connections, Chrome will allow you to see the certificate info by clicking the "Secure" or "Not Secure" tag next to the URL. I clicked that and opened the certificate info window.</li>
  <li>There is a tab called "Details" where I was able to save the certificate to my computer.</li>
  <li>Once the certificate was saved, I could right-click it and there was a right-click option called "Install Certificate".</li>
  <li>I installed the certificate just clicking next and leaving the values as default. After that the Angular app now makes GET, POST, PUT, etc requests as expected, and when I copy the Web API URLs into Chrome, Chrome now says the connection is secure rather than not secure as it was doing before.</li>
  </ol>