Last post Apr 05, 2019 01:52 AM by Xing Zou
Apr 04, 2019 08:06 PM|machurian|LINK
CORS does not work as expected using aspnet core 2.2 web api project.
I have taken the code from cors documentation.
Lets start with a GET request. My client url is http://localhost:8080.
builder.WithOrigins("http://localhost:8080"); This works.
builder.WithOrigins("http://localhost:8081"); This causes cors error which is correct
builder.WithOrigins("http://localhost:8080").WithMethods("POST"); This allows GET requests through when it shouldn't. builder.WithOrigins("http://localhost:8080").WithMethods("POST");This STOPS POST requests through when
I have also used ALL the allow methods and my POSTs wont work. The GETs always work. The cors error is being thrown when the OPTIONS request is sent.
How can I fix this issue?
Apr 04, 2019 08:23 PM|mgebhard|LINK
The POST is probably throwing an exception If the API is configured correctly. Use the browser's dev tools (Network View) to View the response. You can also use PostMan to test the API.
Share all the relevant code if you want community assistance.
Apr 04, 2019 10:24 PM|bruce (sqlwork.com)|LINK
check this thread:
Apr 05, 2019 01:52 AM|Xing Zou|LINK
Have you tried to add `AllowAnyHeader` like
You could refer to How to enable CORS in ASP.net Core WebAPI
Besides,Preflight requests (OPTIONS) do not send auth info to server. So, you need to enable Anonymous Auth if you have used authentication, refer to