django-allauth google 回调 url 不在生产环境中工作

django-allauth google callback url not working on production

我已经使用 django allauth.

集成了 google 登录

对于我的本地人来说,它工作正常。

但对于生产 url 它不起作用。

对于生产它重定向到

localhost:8054/accounts/google/login/callback/?state=U0Y1kkth3jNB&code=4%2FbQFuzMf9I-RTXYJUJ-IhUyx36O-gAV00qFvtQHl3nNHzP_QVDJCfe-5f4a1zR12t_P8PgizD-cc95Hhk497fRyY&scope=profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile

预期:

mysite.com/accounts/google/login/callback/?state=U0Y1kkth3jNB&code=4%2FbQFuzMf9I-RTXYJUJ-IhUyx36O-gAV00qFvtQHl3nNHzP_QVDJCfe-5f4a1zR12t_P8PgizD-cc95Hhk497fRyY&scope=profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile

本地(工作):

in google api 

Authorised redirect URIs = 127.0.0.1:8000/accounts/google/login/callback/

制作:

Authorised redirect URIs = mysite.com/accounts/google/login/callback/

我通过 X-Forwarded-Host

解决了这个问题

在settings.py

USE_X_FORWARDED_HOST = True