Getting the following error of CORS in our .NET Core and Angular project version 8.6.0.0
Process of getting this error :
The Page consists of 2 end point APIs integrated in it. One is GetLeadsList (GET Call) and another is RegisterLead (POST call) - POST happens through pop-up. Both the APIs are present in the provided screenshot.
There is no error generated when called with the AppService using RestSharp But when the same url is hit by using the service calls, it generates a CORS issue.
Can you help please ? Unable to understand why we are getting the CORS issue CORS issue .
Thanks.
7 Answer(s)
-
0
hi
Are there related error messages in the logs of the api application?
-
0
No there are no such errors received in the logs of api application... It is actually a straight forward api call that is being made. But when i checked... there were no errors in the log file.
The api calls are made from our aspnetzero template to the azure portal system of the client... the client has all the logic apps made ready, and to which we are hitting the api. We have already configured CORS to accept * for domain. Does not work from postman. Works on Azure.
-
0
Hi @omkarchoudhari,
The app created on Azure also has CORS configuration. Could you check if it is enabled or not ?
-
0
Hello,
So far we have tried the following :
- We have Azure CORS already configured , added wildcard (*) so that it can accept any HTTPS /HTTP requests.
- We have used HTTP Proxies to take care of CORS related issues
- We also tried using chrome extension for CORS. But it still gives CORS error while calling API
- We also tried with creating a service in Angular to directly call the remote API (Without using service proxies). Still we get same error.
- I have attached the Azure configuration image here for your reference.
Even after 4 days of troubleshooting we are stuck with this issue. Apprecite your help urgently....
-
0
Hi @omkarchoudhari,
Did you try disabling Azure CORS ? If so, we can arrange an online meeting for Monday and help you via remote connection.
-
0
Hello @ismcagdas,
We are still stuck with the CORS issue described above. Have tried all possible solution without success. Is it possible to have a screen sharing session on MS Teams tomorrow to troubleshoot the issue ? Or even via Remote connection. Please inform suitable time for this .
Thanks
-
2
Hello,
Finally got this error resolved !!!!
So the first thing i changed in the apim is adding up of the inbound processing. This is the change:
<allowed-origins> <origin></origin> </allowed-origins> <allowed-methods preflight-result-max-age="6000"> <method></method> </allowed-methods> <allowed-headers> <header></header> </allowed-headers> <expose-headers> <header></header> </expose-headers>
- Then i made the change in my service file for posting a new resource as follows:
so this is the change made in the leadsservice app for handling the post call.