Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,467,448
Community Members
 
Community Events
177
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

Atlassian Community Events