cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid Access-Control-Allow-Headers error

Highlighted
New Contributor

How to avoid Access-Control-Allow-Headers error

I am getting "Failed to load http://xxxx-api/health: Request header field chain-id is not allowed by Access-Control-Allow-Headers in preflight response." when I hit the "Try it out!" button on my API page.  In searching for answers I came across a suggestion (4 years old) (https://stackoverflow.com/questions/19240720/swagger-empty-listing-with-no-api) which suggests creating an ApiOriginFilter, ApiListingResource, and ApiListingResourceJSON.  That page talks about incorporating the mention of these into web.xml - but the other part of the story is that we do not have a web.xml, so I've tried using @bean to define the ApiOriginFilter and FilterRegistrationBean in our config file.  The first problem I'm running into as I'm trying to build is, the examples import com.wordnik.swagger.jaxrs.listing.ApiListing and com.wordnik.swagger.jaxrs.listing.JavaApiListing.  I can't figure out how to include these in my build - no matter what I add to my gradle build, the package comes up as not found, and when I search I can find nothing recent or relevant. There has GOT to be a better way to do this!

 

Can anyone suggest a way of avoiding that Access-Control-Allow-Headers error?

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2