From 92912c5890bb1de2223553596b262b6a008fb8b5 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Tue, 24 Feb 2026 07:53:11 +0100 Subject: [PATCH] fix: test connection reads form values instead of saved config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Kapcsolat tesztelése" button sent an empty POST to /settings/test, which read from the (possibly empty) config file on disk. Now sends the current form values so testing works before clicking Save. Co-Authored-By: Claude Opus 4.6 --- README.md | 4 ++-- app/main.py | 9 +++++---- app/templates/settings.html | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4de56fb..8bc33ee 100644 --- a/README.md +++ b/README.md @@ -107,11 +107,11 @@ volumes: ## Building -On the build server (192.168.0.180): +On the build server (kisfenyo@192.168.0.180): ```bash cd ~/build/recipe-importer -./build.sh 0.1.0 --push +./build.sh X.X.X --push ``` ## Web UI diff --git a/app/main.py b/app/main.py index 18ce347..f619083 100644 --- a/app/main.py +++ b/app/main.py @@ -50,12 +50,13 @@ def settings(): @app.route("/settings/test", methods=["POST"]) def settings_test(): - """AJAX endpoint — test Mealie connection.""" - cfg = config.load() - if not cfg.get("mealie_url") or not cfg.get("mealie_api_key"): + """AJAX endpoint — test Mealie connection using form values.""" + url = (request.form.get("mealie_url") or "").strip().rstrip("/") + key = (request.form.get("mealie_api_key") or "").strip() + if not url or not key: return jsonify({"ok": False, "error": "Nincs megadva Mealie URL vagy API kulcs."}) try: - client = MealieClient(cfg["mealie_url"], cfg["mealie_api_key"]) + client = MealieClient(url, key) info = client.test_connection() return jsonify({"ok": True, "data": info}) except Exception as exc: diff --git a/app/templates/settings.html b/app/templates/settings.html index 52af1ae..8611330 100644 --- a/app/templates/settings.html +++ b/app/templates/settings.html @@ -39,7 +39,8 @@ async function testConnection() { result.innerHTML = ''; try { - const resp = await fetch('/settings/test', { method: 'POST' }); + const form = new FormData(document.querySelector('form')); + const resp = await fetch('/settings/test', { method: 'POST', body: form }); const data = await resp.json(); if (data.ok) { const v = data.data.version || '?';