I would like DRF to use for serialized hyperlinks:
http://<mydomain.com>/api/v1/endpoint
but not
http://127.0.0.1/api/v1/endpoint
Could this be configured in Django or is it related to my http server configuration (gunicorn + nginx)?
Just set the host header for django.
Example for nginx:
location /api/ { proxy_set_header Host $host; proxy_pass http://127.0.0.1:8000; }
if you use https also add:
proxy_set_header X-Forwarded-Proto https;
and everything works fine :)