Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All header names put onto Access-Control-Request-Headers and values discarded #2395

Closed
sunshineo opened this issue Sep 8, 2016 · 1 comment

Comments

@sunshineo
Copy link

When reporting a bug, please provide the following details:

  • swagger-ui version
    latest master branch
  • a swagger file reproducing the issue
    client auth issue, see attached screenshot

All I did was follow the README.md and added these 2 lines in dist/index.html

      window.swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("test", "XXXX", "header"));
      window.swaggerUi.api.clientAuthorizations.add("key2", new SwaggerClient.ApiKeyAuthorization("test2", "XXXX2", "header"));

headers1

However when the request is sent, I got something does not make any sense.
The header names are added to Access-Control-Request-Headers
headers2

@sunshineo sunshineo changed the title Why are all header names put onto Access-Control-Request-Headers and values discarded? All header names put onto Access-Control-Request-Headers and values discarded Sep 8, 2016
@sunshineo
Copy link
Author

The problem is NOT that it got put on the wrong header. That IS the right header to put on. The screenshot showed the request is for OPTION not the actual GET. So the problem is with the service side. The service is a dropwizard service and CORS is turned on using https://stackoverflow.com/questions/25775364/enabling-cors-in-dropwizard-not-working https://bl.ocks.org/tifletcher/567b4a5f5874d7a8ec65

Now the problem is that "api_key" is not white listed as a CORS allowed header.
I added this line on the service and it works now.

corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin,api-key");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant