diff --git a/README.md b/README.md index 7d904f2..de0ecc2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Set secure MariaDB passwords in `.env`. Then, set at least these values in ```json { - "abbr": "api", + "abbr": "vtc", "name": "Drivers Hub", "domain": "hub.example.com", "prefix": "/api", @@ -75,8 +75,9 @@ from `config_sample.json`. Restart the backend after you change Use the same database password in `.env` and `config/config.json`. Set `domain` to the public host name of the backend. Do not include a protocol or path. -Set `prefix` to `/{abbr}` when you use the official frontend. The -`client-config` plugin uses this relation to create frontend API URLs. +Set `abbr` to a short identifier for the VTC. The Docker frontend deployment +derives the API base URL from its `VITE_CONFIG_URL`, so `abbr` does not have to +match `prefix`. Create an hCaptcha site for the public frontend domain. Set its secret in the `captcha.secret` value. Set the related public site key as `VITE_HCAPTCHA_SITEKEY` in the frontend deployment. @@ -86,10 +87,10 @@ backend expects the singular names shown above. This deployment configuration enables all built-in plugins by default. Keep `client-config` separate in `external_plugins`. -The deployment patch synchronizes the plugin list from `config/config.json` to -the stored frontend configuration when the backend starts. Other frontend -settings in MariaDB stay unchanged. Restart the backend after you enable or -disable a plugin. +The deployment patch synchronizes `abbr` and the plugin list from +`config/config.json` to the stored frontend configuration when the backend +starts. Other frontend settings in MariaDB stay unchanged. Restart the backend +after you change `abbr` or enable or disable a plugin. ## Configure external connections diff --git a/docker/client-config.patch b/docker/client-config.patch index 3d02d03..7717f28 100644 --- a/docker/client-config.patch +++ b/docker/client-config.patch @@ -1,26 +1,28 @@ --- a/src/external_plugins/client-config.py +++ b/src/external_plugins/client-config.py @@ -17,0 +18,7 @@ -+def normalize_client_config(config, plugins): ++def normalize_client_config(config, plugins, abbr): + if not config["api_host"].startswith(("http://", "https://")): + config["api_host"] = f"https://{config['api_host']}" ++ config["abbr"] = abbr + config["plugins"] = plugins + return config + + @@ -24 +31 @@ - return json.loads(config) -+ return normalize_client_config(json.loads(config), app.config.plugins) ++ return normalize_client_config(json.loads(config), app.config.plugins, app.config.abbr) @@ -37 +44 @@ - config = json.loads(t[0][0]) -+ config = normalize_client_config(json.loads(t[0][0]), app.config.plugins) ++ config = normalize_client_config(json.loads(t[0][0]), app.config.plugins, app.config.abbr) @@ -298 +305 @@ - "api_host": config["domain"], + "api_host": f"https://{config['domain']}", @@ -306,0 +314,6 @@ + else: + frontend_conf = json.loads(t[0][2]) -+ if frontend_conf.get("plugins") != config["plugins"]: ++ if frontend_conf.get("abbr") != config["abbr"] or frontend_conf.get("plugins") != config["plugins"]: ++ frontend_conf["abbr"] = config["abbr"] + frontend_conf["plugins"] = config["plugins"] + frontend_conf = convertQuotation(json.dumps(frontend_conf)) + cur.execute(f"UPDATE settings SET sval = '{frontend_conf}' WHERE skey = 'client-config/meta'")