Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,477
Community Members
 
Community Events
165
Community Groups

How To Overcome CORS error for OpenAPI Swagger add in

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

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:*" .

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

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?

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

add added the CORS policy to my azure API:

API CORS policy.jpg

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

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
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

367 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you