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

Multiple Access-Control-Allow-Credentials response headers #2629

Closed
l3ender opened this issue Oct 23, 2019 · 1 comment · Fixed by #2718
Closed

Multiple Access-Control-Allow-Credentials response headers #2629

l3ender opened this issue Oct 23, 2019 · 1 comment · Fixed by #2718

Comments

@l3ender
Copy link
Contributor

l3ender commented Oct 23, 2019

Branch/Environment/Version

  • Branch/Version: latest in docker as of 2019-10-23
    • gateway: 2.9.1
    • dashboard: 1.9.1
  • Environment: on-prem

Describe the bug
When configuring "Allow credentials" in CORS support on an API, multiple Access-Control-Allow-Credentials can be returned if the upstream API adds the header to the response.

Browsers do not support multiple of this header; Chrome logs the following in console:

Access to XMLHttpRequest at 'http://www.tyk-test.com:8080/testapi' from origin 'http://localhost:4200' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Credentials' header in the response is 'true, true' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Reproduction steps

  1. Create an API pointing to upstream http://httpbin.org/ server.
  2. Configure CORS on the API and enable "Allow credentials".
  3. Test the API with Postman and set Origin header on request.

Actual behavior
Multiple Access-Control-Allow-Credentials headers are returned in the response.

Expected behavior
Only a single Access-Control-Allow-Credentials header should be returned.

Screenshots/Video
Screen Shot 2019-10-23 at 2 41 40 PM

Configuration (tyk config file):
API CORS config:

    "CORS": {
      "enable": true,
      "max_age": 600,
      "allow_credentials": true,
      "exposed_headers": [],
      "allowed_headers": [],
      "options_passthrough": false,
      "debug": false,
      "allowed_origins": [],
      "allowed_methods": [
        "GET"
      ]
    },

Additional context
This is closely related to #2199. I believe it'd be worth the effort to review all CORS headers to avoid other similar issues.

@maciejwojciechowski
Copy link
Contributor

verified

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

Successfully merging a pull request may close this issue.

5 participants