fix(api/settings.common): address pre-commit hook

This commit is contained in:
jon r 2024-09-04 11:23:05 +02:00
parent ee98d3159c
commit b79b316ab8
1 changed files with 14 additions and 5 deletions

View File

@ -226,16 +226,25 @@ List of allowed hostnames for which the Funkwhale server will answer.
try: try:
FUNKWHALE_PORT = env.int("FUNKWHALE_PORT") FUNKWHALE_PORT = env.int("FUNKWHALE_PORT")
except: except Exception as e:
logger.warning("Funkwhale is served from default port.") logger.warning(f"Funkwhale is served from default port. {e}")
try: try:
CSRF_TRUSTED_ORIGINS = [urlparse('//' + o + (':' + str(FUNKWHALE_PORT) if (FUNKWHALE_PORT != 80) else ''), FUNKWHALE_PROTOCOL).geturl() for o in ALLOWED_HOSTS] CSRF_TRUSTED_ORIGINS = [
except: urlparse(
CSRF_TRUSTED_ORIGINS = [urlparse('//' + o, FUNKWHALE_PROTOCOL).geturl() for o in ALLOWED_HOSTS] "//" + 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 List of origins that are trusted for unsafe requests
We simply consider all allowed hosts to be trusted origins 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 See https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-trusted-origins
""" """