CORS Access Control Allow Origin Error to while calling the registered app from different web browser

Prashant Meshram 41 Reputation points
2022-11-21T05:27:16.947+00:00

Hi Team,

I am trying to re-run a pipeline using rest API for this I have registered an APP in azure and got the client ID and secret. I was successfully able to call the API through POSTMAN and also powershell script.

But when I am trying to call it from the localhost server or another production environment (different web browser) then it is giving me CORS error. To overcome this I created an API Management service and enabled the CORS policies in the all API inbound / outbound section.

<policies>
<inbound>
<cors allow-credentials="true">
<allowed-origins>
<origin>https://apim-gateway-resource.developer.azure-api.net</origin>
<origin>http://localhost:4567</origin>
<origin>https://localhost:4567</origin>
<origin>http://24.9.126.177</origin>
<origin>https://24.9.126.177/</origin>
<origin>https://877104.apps.zdusercontent.com</origin>
<origin>http://127.0.0.1:5500</origin>
<origin>http://localhost:5500</origin>
</allowed-origins>
<allowed-methods preflight-result-max-age="300">
<method>POST</method>
</allowed-methods>
<allowed-headers>
<header></header>
</allowed-headers>
<expose-headers>
<header>
</header>
</expose-headers>
</cors>
</inbound>
<backend>
<forward-request />
</backend>
<outbound>
<set-header name="Access-Control-Allow-Origin" exists-action="override">
<value>@(context.Request.Headers.GetValueOrDefault("Origin",""))</value>
</set-header>
<set-header name="Access-Control-Allow-Credentials" exists-action="override">
<value>true</value>
</set-header>
</outbound>
<on-error />
</policies>

But still getting the same CORS error.

Could you guys please help me out with this.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,784 questions
{count} votes