How To Overcome CORS error for OpenAPI Swagger add in

Jean Marie Koon November 12, 2018

I am getting the below error.  I tried adding CORS custom header to my website http response on the server that hosts the API.  It had no effect.  Any other ideas?

Errors

Hide

Fetch error

Failed to fetch http://qaapolloapi.gcmlp.com/portfolios

Fetch error

Possible cross-origin (CORS) issue? The URL origin (https://qaapolloapi.gcmlp.com) 
does not match the page (https://confluence-open-api.herokuapp.com).
Check the server returns the correct 'Access-Control-Allow-*' headers.

 

2 answers

0 votes
Andrey Stepanov June 17, 2021

It depends on how the remote host supports the CORS. In my OpenApi app  I'm parsing the URL to request the document from the API that includes "Access-Control-Allow-Origin:*" .

0 votes
Scott
Contributor
November 12, 2018

Hi Jean,

I am from the company that produces Open API Documentation For Confluence, and I'd love to help you get it working.

Firstly, if you haven't done so already, you may want to check out the CORS section in our documentation, which may provide some useful help.

In particular, the header you need to add to the URL that hosts your API is:

`Access-Control-Allow-Origin: https://confluence-open-api.herokuapp.com`

If this still doesn't work, you may wish to check for any errors in the browser console; which often provides more clues as to what the problem is.

Finally, if you still need further help, please feel free to log a support request.

I hope this helps. Good luck!

Kind regards,

Scott

Jean Marie Koon November 14, 2018

So this is what I see in the browser console:  

Failed to load resource: net::ERR_NAME_NOT_RESOLVED

I suppose this is because I am calling an http: instead of an https:

When I try another API (hosted in Azure) this is what I see:

Access to fetch at 'https://gcm-pub-masterentitydata-uat.azurewebsites.net/api/portfolios' from origin 'https://confluence-open-api.herokuapp.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Is access to Azure APIs supported?

Scott
Contributor
November 14, 2018

Hi Jean,

Yes, it should be possible to use Azure APIs, by adding a CORS policy to your API.

If you go to your Azure API, and under "All Operations", click the "+ Add Policy" link in "Outbound Processing".

In the "Add Outbound Policy" screen, click "Other Policies", and select CORS from the Cross Domain Policies list.

Then in <allowed-origins>, add https://confluence-open-api.herokuapp.com.

Hope this helps.

Regards,

Scott

Jean Marie Koon November 15, 2018

add added the CORS policy to my azure API:

API CORS policy.jpg

But I am still getting the error message as above post.

Scott
Contributor
November 15, 2018

Hi Jean,

At this point it may be best if we move this discussion from the Developer Community to a support ticket, so that our team can assist you further.

In the support ticket, you will be able to provide us with more specific details (such as the URL you are trying to load, that you may otherwise not be comfortable sharing publicly with the community), so that we can work with you to determine the problem.

If you would like to log a support request, you can use the following link, 

https://oharagroup.atlassian.net/servicedesk/customer/portal/1/create/1

Kind regards,

Scott

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events