diff --git a/backend/geonature/utils/config_schema.py b/backend/geonature/utils/config_schema.py index 395bc4e347..1e5648df7b 100644 --- a/backend/geonature/utils/config_schema.py +++ b/backend/geonature/utils/config_schema.py @@ -4,6 +4,8 @@ import os +from urllib.parse import urlsplit + from marshmallow import ( Schema, fields, @@ -590,3 +592,13 @@ def insert_module_config(self, data, **kwargs): continue data[module_code] = get_module_config(dist) return data + + @post_load + def infer_application_root(self, data, **kwargs): + """ + Determine APPLICATION_ROOT from URL_APPLICATION + The parameter APPLICATION_ROOT is used by Flask tu set the cookie path (use by Flask-Login for Flask Admin) + """ + split_url = urlsplit(data["URL_APPLICATION"]) + data["APPLICATION_ROOT"] = split_url.path if split_url.path else "/" + return data