Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resolving domain name on Django-rest-framework HyperlinkedModelSerializer

I would like DRF to use for serialized hyperlinks:

http://<mydomain.com>/api/v1/endpoint

rather than

http://127.0.0.1/api/v1/endpoint

Can this be configured within Django or is it related to my http server configuration (gunicorn+nginx)?

like image 588
imagineerThat Avatar asked Oct 20 '22 17:10

imagineerThat


1 Answers

Just set host header for django.

Example for nginx:

location /api/ { 
    proxy_set_header Host      $host; 
    proxy_pass http://127.0.0.1:8000;
}
like image 124
Nikolay Fominyh Avatar answered Oct 22 '22 19:10

Nikolay Fominyh