Skip to content

Localhost url constructed without port number in redoc and swagger templates #103

@luisgc93

Description

@luisgc93

When building the url_name in the swagger and redoc views, reverse uses the current request in the context. If we run our project locally, that would be localhost in the app container but localhost:port_number for the instance outside the app container:

{'url_name': reverse(self.url_name, request=request)},

To reproduce, install drf-spectacular v0.9.7 or above and go to your project's doc page on localhost e.g. localhost:8030/mydocs/redoc/. The following error will show up (notice the missing port number in the request):

Error downloading http://localhost/docs/schema/ Failed to fetch
Stack trace
Error: Error downloading http://localhost/docs/schema/ 
Failed to fetch
    at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:63:6628
    at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:122:36080

TypeError: Failed to fetch

ReDoc Version: 2.0.0-rc.30
Commit: 5bace30

When using v0.9.6 the normal response is rendered successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions