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:
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
"""