marshmallow-code / marshmallow-code/flask-smorest

How to show docs with nginx url prefix set?

Open
#606 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
717
Forks
77
Avg merge
7h 49m
Merged PRs (30d)
3

Description

I have project which uses flask-smorest and when I run it locally it shows docs on url `/docs/swagger`. But on my production server I have in nginx setup to append `api/` prefix on each url and then docs are not showing because flask-smorest expects openapi.json on `docs/openapi.json` but mine nginx append `api/` and openapi.json is visible on url `api/docs/openapi.json` so I keep getting error:

![image](https://github.com/marshmallow-code/flask-smorest/assets/6032955/f98471cb-b4eb-4e59-872e-13874e804dd3)

So basically how to setup configuration so it loads docs? Here are mine configuration in project for flask-smorest:

```

app = Flask(__name__)
app.config["API_TITLE"] = "Test API"
app.config["API_VERSION"] = "v1"
app.config["OPENAPI_VERSION"] = "3.0.2"
app.config["OPENAPI_URL_PREFIX"] = "/docs"
app.config["OPENAPI_REDOC_PATH"] = "/redoc"
app.config["OPENAPI_REDOC_URL"] = "https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.30/bundles/redoc.standalone.js"
app.config["OPENAPI_SWAGGER_UI_PATH"] = "/swagger"
app.config["OPENAPI_SWAGGER_UI_URL"] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@3.25.5/"

api = Api(app)
api.register_blueprint(blp_test)
```

Contributor guide

Open the contributing guide

Research direction

Start with the Flask-Smorest configuration shown in the issue, then trace how OPENAPI_URL_PREFIX, OPENAPI_SWAGGER_UI_PATH, and the generated schema URL interact with the nginx api/ prefix. Confirm the configuration and proxy behavior against the reported URLs; done means the Swagger UI loads and retrieves the schema at the prefixed endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.