diff --git a/api/config/settings/common.py b/api/config/settings/common.py index 24ced4ae7..389a6100d 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -226,16 +226,25 @@ List of allowed hostnames for which the Funkwhale server will answer. try: FUNKWHALE_PORT = env.int("FUNKWHALE_PORT") -except: - logger.warning("Funkwhale is served from default port.") +except Exception as e: + logger.warning(f"Funkwhale is served from default port. {e}") try: - CSRF_TRUSTED_ORIGINS = [urlparse('//' + o + (':' + str(FUNKWHALE_PORT) if (FUNKWHALE_PORT != 80) else ''), FUNKWHALE_PROTOCOL).geturl() for o in ALLOWED_HOSTS] -except: - CSRF_TRUSTED_ORIGINS = [urlparse('//' + o, FUNKWHALE_PROTOCOL).geturl() for o in ALLOWED_HOSTS] + CSRF_TRUSTED_ORIGINS = [ + urlparse( + "//" + o + (":" + str(FUNKWHALE_PORT) if (FUNKWHALE_PORT != 80) else ""), + FUNKWHALE_PROTOCOL, + ).geturl() + for o in ALLOWED_HOSTS + ] +except Exception: + CSRF_TRUSTED_ORIGINS = [ + urlparse("//" + o, FUNKWHALE_PROTOCOL).geturl() for o in ALLOWED_HOSTS + ] """ List of origins that are trusted for unsafe requests We simply consider all allowed hosts to be trusted origins +See DJANGO_ALLOWED_HOSTS in .env.dev for details See https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-trusted-origins """