Swagger UI & NetworkError when attempting to fetch resource. http://localhost/swagger.json

Pros,

I have the latest version of Xibo pulled, built, and deployed. I’m running the containers locally but when I go to swagger UI I receive the following error. I have verified I can access http://localhost/swagger.json (i.e. Xibo CMS web is running) and I can explore Swagger UI’s petstore example using http://petstore.swagger.io/v2/swagger.json on my local swagger UI server. What am I missing?

NetworkError when attempting to fetch resource. http://localhost/swagger.json

swagger_localhost_issue

Its CORS i’m afraid - localhost:8080 and localhost are different “origins” and therefore javascript doesn’t have permission to access between them.

you could try mapping in a modified .htaccess file to the CMS container, which replicated the current behaviour, but also added CORS headers for /swagger.json - or assuming your swagger container joins the same network you could look at modifying that to pass the request for swagger.json to http://cms/swagger.json


Edit: or you could have a proxy container in the same compose file which proxies swagger-ui requests into the swagger container and everything else into the cms container

Thanks Dan!

I know this is me being lazy. I decided to just use firefox plugin (CORS Everywhere) to apply CORS header as a work-around so I can focus on development instead of annoying configuration stuff.

Warning: If you are not familiar with CORS and danger of a blanket application of this header to every browser request then you should not use this work-around. This work-around circumvents well intended security.