0

I'm trying not to specify the full path of the web app in the settings to make it as portable as possible.

However,

with MEDIA_URL="/media/", an URL returned from a Django FileField model is http://localhost/media/....

with MEDIA_URL="//example.com/media/", the URL returned is http://example.com/media/....

But the schema (http/s) and domain (example.com) should match those of the requesting page. How can I do this?

The Django app is served through Nginx in combination with Gunicorn.

bluppfisk
  • 2,538
  • 3
  • 27
  • 56

1 Answers1

1

It sounds like nginx and Django are not configured to pass and use http host name (e.g. X-Forwarded-Host header). This looks like a good answer - https://stackoverflow.com/a/58044808/6865

edgars
  • 1,038
  • 1
  • 7
  • 17