Discussion:
Browsable API + reverse proxy
m***@swordfish.co.za
2018-04-25 09:04:29 UTC
Permalink
My DRF app is currently being served at https://myapp.com/api/ with the
nginx config below:

location /api/ {

rewrite /api(.*) $1 break;
client_max_body_size 20M;
client_body_timeout 300s;
uwsgi_read_timeout 300s;
uwsgi_send_timeout 300s;
uwsgi_pass django-myapp;
include /etc/nginx/conf.d/uwsgi_params.conf;
}


The browsable API loads up, but when trying to log in renders a 404 page.
The URL is "https://myapp.com/api-auth/login/" instead of
"https://myapp.com/api/api-auth/login/" . Is there any way to get around
this and change the API root URL ?

Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
m***@swordfish.co.za
2018-04-25 10:27:10 UTC
Permalink
Seems like setting FORCE_SCRIPT_NAME to "/api/" does the trick...
Post by m***@swordfish.co.za
My DRF app is currently being served at https://myapp.com/api/ with the
location /api/ {
rewrite /api(.*) $1 break;
client_max_body_size 20M;
client_body_timeout 300s;
uwsgi_read_timeout 300s;
uwsgi_send_timeout 300s;
uwsgi_pass django-myapp;
include /etc/nginx/conf.d/uwsgi_params.conf;
}
The browsable API loads up, but when trying to log in renders a 404 page.
The URL is "https://myapp.com/api-auth/login/" instead of "
https://myapp.com/api/api-auth/login/" . Is there any way to get around
this and change the API root URL ?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Arthur Jacobs
2018-07-26 18:37:55 UTC
Permalink
Hey, I'm having the same problem.
Can you elaborate on your answer?
Post by m***@swordfish.co.za
Seems like setting FORCE_SCRIPT_NAME to "/api/" does the trick...
Post by m***@swordfish.co.za
My DRF app is currently being served at https://myapp.com/api/ with the
location /api/ {
rewrite /api(.*) $1 break;
client_max_body_size 20M;
client_body_timeout 300s;
uwsgi_read_timeout 300s;
uwsgi_send_timeout 300s;
uwsgi_pass django-myapp;
include /etc/nginx/conf.d/uwsgi_params.conf;
}
The browsable API loads up, but when trying to log in renders a 404 page.
The URL is "https://myapp.com/api-auth/login/" instead of "
https://myapp.com/api/api-auth/login/" . Is there any way to get around
this and change the API root URL ?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-07-27 11:14:23 UTC
Permalink
https://docs.djangoproject.com/en/2.0/ref/settings/#force-script-name

Basically set that to the root of the URL where you want the scripts to be
served from. In this case, it overrides the default from /api/api-auth/..
to /api-auth/...
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...