Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

The swagger urls are not using the SCRIPT_NAME header #494

Closed
bobkarreman opened this issue Jul 21, 2016 · 6 comments
Closed

The swagger urls are not using the SCRIPT_NAME header #494

bobkarreman opened this issue Jul 21, 2016 · 6 comments

Comments

@bobkarreman
Copy link

I have a django app deployed in a subfolder with a reverse proxy.

For django to work properly I set the SCRIPT_NAME header, but swagger is not using that.
Causing all urls to be wrong.

@marcgibbons
Copy link
Owner

@bobkarreman Can you be more specific in describing the problem?

@bobkarreman
Copy link
Author

Yes of course, sorry if its not clear.

I have a django app with django-rest-framework and django-rest-swagger deployed like this:

/my-subfolder/actual-django-folder/swagger/
So my reverse proxy in nginx is serving my django_app on /my-subfolder/ while my django app code wise only knows about /actual-django-folder/* so when I load the swagger json all the path's in there only contain the /actual-django-folder missing the my-subfolder causing the swagger-ui to send the requests to the wrong url.
So the urls its pointing to is /actual-django-folder/api-endpoint while it should point to /my-subfolder/actual-django-folder/api-endpoint.

I had the same issue in the beginning with the django-admin but that I fixed by setting the SCRIPT_NAME header from nginx.

@marcgibbons I hope it makes a bit more sense now :-)

@marcgibbons
Copy link
Owner

@bobkarreman Yes, thank you! To summarize then, the renderers are working correctly, but the URLs in the specification to the endpoints is incorrect?

This is likely an issue to open on the Django REST Framework project, since it is responsible for generating the schema describing the API and setting the URIs.

However, I am working on providing configurations and overrides in this project, so we could set a base path and all the endpoints then become relative to that base.

@bobkarreman
Copy link
Author

@marcgibbons Thnx! I will create a ticket on the Django REST Framework then as well to make sure that the schema generation is done correctly on that side.

And allowing to overwrite the base path in a configuration also seems like a nice alternative option.

@tomchristie
Copy link
Contributor

Resolved by 3.4.1. SchemaGenerator(url=...) or DefaultRouter(schema_url=...

@marcgibbons
Copy link
Owner

Thank you! Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants