wordnik/swagger-ui — Issue #11: Access-Control-Allow-Origin
Author: apotheos
Created: 2012-02-15 02:04:04+00:00
State: open

There was an issue similar to the one I'm having, with a few important differences, posted a while ago:
https://github.com/wordnik/swagger-ui/issues/2

My issue is essentially the same as the OP. The differences here are in our implementations.

Fehguy posted this in response to the OP's question:

------------START POST-------------
Hi, that's possible. What server did you deploy? The java version or scala one? Or did you roll your own? There was a bug in our ApiOriginFilter which caused the allow orgin to not work.

I can tell you about your last question after you tell me what language/sample app you're working with.

Tony
-------------END POST---------------

I am getting the Access-Control-Allow-Origin problem myself, let me tell you about my setup.
Currently we have a PHP API hosted on one machine, and another machine hosting Swagger-Node-Express and a Swagger-UI. Since Swagger does not currently support auto documentation for PHP APIs, I have had to create my own doc template in javascript to be hosted from the node server. I used the node server's sample files as a template and modified them from there to create the Javascript files which are exported to .json. The Swagger-UI is hitting the node server, and all of my hard-coded API doc renders correctly into the UI. The problem happens when I try to use the "Try it now!" sandbox feature of the Swagger-UI. When looking at the errors through Firebug or Chrome, I get the Access-Control-Allow-Origin error on URLs that I can GET by simply copying and pasting it in another tab. Now, I understand one problem this may be solved is by making the API return headers to Allow Access Control, but I was wondering if there is any work around to this or if this is the only solution.