0

I've set up a Django project on a nginx server. But..

  1. Django detects request.get_host() in signup and activation views as localhost and sends email (for activation and password reset) with links like http://localhost/....

  2. I've set up Facebook authorization via social-auth-app-django. But Facebook tries to open redirect_uri in localhost (...redirect_uri=http:localhost/oauth/complete/facebook...)

  3. Inside django admin TinyMCE editor Filebrowser also refers to localhost..

How to fix these problems? Or it seems one solution can fix all of them.

Thank you for your time and help.

Andy
  • 654
  • 7
  • 17

1 Answers1

0

Did you tried changing your Site.domain and Site.name in admin panel or via shell? from django.contrib.sites.models import Site

https://docs.djangoproject.com/en/2.1/ref/contrib/sites/

It's used in many cases such as emails by default.

slqq
  • 245
  • 2
  • 3
  • 13
  • Changed `example.com` to my domain. But still not works. Facebook still tries to open `redirect_uri` in localhost. Both `get_current_site(request)` and `request.get_host()` inserts `localhost` in production. – Andy Mar 29 '19 at 08:59
  • 1
    Add this to your django settings 'USE_X_FORWARDED_HOST = True' it replace it's internal address by external address, it's needed when your backend is called from nginx, which address is localhost. – slqq Mar 29 '19 at 13:34
  • Thank you so much! it works (with setting `proxy_set_header` in nginx). – Andy Mar 29 '19 at 15:09