I have a flask restplus app which has an API page documented in a swagger interface.
This page comes up happily and I can use it when it is run locally.
I have it working inside a docker container with the ProxyFix
from WerkZeug
. However when I put that container behind an nginx
instance, I get Uncaught SyntaxError: Unexpected token '<'
on swagger-ui-bundle.js
. Clicking through it's indeed correct as what is being attempted to be rendered as swagger-ui-bundle.js
is in fact a page of HTML, and that >
is the first character of the page.
So what's going on?
How do I fix it to get the swagger page come up?
EDIT:
Turns out that the swagger was being served from /swagger
, not url_prefix/swagger
. This meant that the nginx config was forwarding the request to an angular front end running from /
, which was serving up the html front page and not the js that was expected.
So, the solution to this is to move the swagger to be served from http://<ip>/swagger
to http://<ip>/my_site/swagger
. I've tried a bunch of solution but can't get any of them to serve up the swagger from anywhere but http://<ip>/swagger
, which isn't helpful (and no, hardcoding the nginx config isn't the right solution as we have multiple services using potentially different versions)
So if anyone has an idea how to do that that would be amazing.