R
R
Roman Sokolov2020-04-09 08:53:50
Python
Roman Sokolov, 2020-04-09 08:53:50

How to configure access to swagger.json by domain name?

Hello.
Flask is running on the server via uwsgi (127.0.0.1:56733), access to it is proxied via nginx.
It opens in the browser, but at the same time, JS tries to load swagger.json at the local URL, which ultimately leads to an error:

Fetch errorFailed to fetch http://127.0.0.1:56733/swagger.json

As a result, I can't get the generated documentation for the API.
I also tried installing the ProxyFix middleware.

Application root page code:
from flask import Flask, render_template
from flask_restx import Resource, Api
# from werkzeug.middleware.proxy_fix import ProxyFix
import logging
import os
import shutil

app = Flask(__name__)
# app.wsgi_app = ProxyFix(app.wsgi_app)

api = Api(app, version='1.0', title='My API',
    description='My API',
)

# -- skip --

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-04-09
@jimquery

flask_restx is a fork of Flask-RESTPlus so see here
Swagger UI refers to localhost #223

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question