Flasgger does not load when hostname has a path

609 views Asked by At

I have a Flask application and I've integrated Flasgger for documentation. When I run my app locally, I can access swagger at http://127.0.0.1:5000/apidocs. But when it's deployed to our dev environment, the hostname is https://services.company.com/my-flask-app. And when I add /apidocs at the end of that URL, swagger does not load.

This is how I've configured swagger:


swagger_config = {
    "headers": [],
    "specs": [
        {
            "endpoint": "APISpecification",
            "route": "/APISpecification",
            "rule_filter": lambda rule: True,  # all in
            "model_filter": lambda tag: True,  # all in
        }
    ],
    "static_url_path": "/flasgger_static",
    "specs_route": "/apidocs/",
    "url_prefix": "/my-flask-app", # TODO - redo this for INT deployment
}

When I run this, on my local I can access swagger at http://127.0.0.1:5000/my-flask-app/apidocs/#/, but I think on my dev environment it'd probably be accessible at https://services.company.com/my-flask-app/my-flask-app/api-docs. When I check the console, Flasgger tries to get the css from https://services.company.com/ not https://services.company.com/my-flask-app

Any ideas on how I can resolve this?

0

There are 0 answers