base_url issues in drf_yasg swagger base_url issues in drf_yasg swagger nginx nginx

base_url issues in drf_yasg swagger


You need to tell the Nginx to forward the server port as well. As swager gets the base url port from request header (if not hardcoded as mtshaikh proposed).

eg. something like this this should be in Nginx config

location / {            proxy_set_header Host $host:$server_port;    proxy_pass http://example.com:8000/;}


Not a good solution but defining the complete url in the get_schema_view() in urls.py works!

schema_view = get_schema_view(    openapi.Info( ... ),    url='http://example.net:8080/', # Important bit    public=True,    permission_classes=(permissions.AllowAny,))

Source


Thanks, @Petr Synek for your answers and clue.

We need to tell the Nginx to forward the http_host.

location / {     proxy_set_header Host $http_host;}

This one resolved the above-mentioned issue