Response headers incomplete when making CORS requests
See original GitHub issue- OS: macos
- Browser: chrome
- Version: 66
- Method of installation: npm
- Swagger-UI version: 3.15.0
- Swagger/OpenAPI version: 2.0
Describe the bug you’re encounering
I’ve noticed that when you host swagger-ui on a particular domain and you make calls to a CORS enabled api, not all response headers are shown. I think this may be a bug related to the preflight OPTIONS call, but I may just be misunderstanding something.
To reproduce…
- Run this endpoint with the provided sample data: http://petstore.swagger.io/#/pet/addPet and notice your response will include headers. Likely something like this -
- Download and setup swagger-ui locally following readme instructions for development. Run the same endpoint. This should be hosted at http://0.0.0.0:3200/#/pet/addPet Making the same call I see something like this -
Expected behavior
The response headers should be very similar since the call is made to the same endpoint
Additional context or thoughts
I believe that something is going awry when CORS is required. I tested this assumption by hosting the same petstore swagger document locally at http://0.0.0.0:3200/test.json , removing the host
property making CORS unnecessary. I received this in response -
Of course the actual call failed (404) since i’m not hosting the api, but I do in fact receive the expected response headers from the dev server.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Missing headers in Fetch response - Stack Overflow
I need to make a CORS post request . I need to use fetch because axios 's response is already processed to json....
Read more >Response to preflight request doesn't pass access control check
The server you are making an HTTP request to doesn't send back the correct CORS headers. You have specified an incorrect or incomplete...
Read more >Access-Control-Expose-Headers - HTTP - MDN Web Docs
The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts ...
Read more >Understanding and Resolving CORS Error - Contentstack
Here, the origin refers to the domain where you've hosted the extensions. Also, ensure that the response header has the exact origin URL...
Read more >Fixing Common Problems with CORS and JavaScript
The solution to the issue is for the server to set a response header that allows the browser to make cross-domain requests to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@blortfish, while you’re right in that there’s not really a way to throw out CORS… you do have a couple of options while you wait to hear back:
--disable-web-security
command line flag will get you there. Also consider browser extensions, looks like there’s a few out there that claim to be able to toggle CORS enforcement on and off.@shockey thank you for all of the suggestions and information. These are all great options to consider. In the end we will be recommending that our users either whitelist headers in
Access-Control-Expose-Headers
or allow*
.