From 22a3da61c309f50faff439dd4f680c89ba3e5e3d Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 18 Apr 2026 17:12:34 -0700 Subject: [PATCH] fix: frontend concurrent-mount errors, nginx routing, and browser UX (#98 #106 #107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - App.vue: lazy-mount pattern (v-if + v-show) so non-active tabs only mount on first visit, eliminating concurrent onMounted calls across all components (#98) - nginx.cloud.conf: add /kiwi/api/ location to proxy API calls on direct-port access (localhost:8515); was serving SPA HTML → causing M.map/filter/find TypeError chain on load (#98) - nginx.cloud.conf: $host → $http_host so 307 redirects preserve port number (#107) - RecipeBrowserPanel: show friendly "corpus not loaded" notice and skip auto-select when all category counts are 0, instead of rendering confusing empty buttons (#106) - Defensive Array.isArray guards in inventory store, mealPlan store, ReceiptsView --- docker/web/nginx.cloud.conf | 18 +++++++++++++++++- frontend/src/App.vue | 17 +++++++++++------ frontend/src/components/ReceiptsView.vue | 3 ++- frontend/src/components/RecipeBrowserPanel.vue | 18 ++++++++++++++---- frontend/src/stores/inventory.ts | 3 ++- frontend/src/stores/mealPlan.ts | 3 ++- 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/docker/web/nginx.cloud.conf b/docker/web/nginx.cloud.conf index 4a3d316..85e509b 100644 --- a/docker/web/nginx.cloud.conf +++ b/docker/web/nginx.cloud.conf @@ -8,7 +8,7 @@ server { # Proxy API requests to the FastAPI container via Docker bridge network. location /api/ { proxy_pass http://api:8512; - proxy_set_header Host $host; + proxy_set_header Host $http_host; # Prefer X-Real-IP set by Caddy (real client address); fall back to $remote_addr # when accessed directly on LAN without Caddy in the path. proxy_set_header X-Real-IP $http_x_real_ip; @@ -20,6 +20,22 @@ server { client_max_body_size 20m; } + # Direct-port LAN access (localhost:8515): when VITE_API_BASE='/kiwi', the frontend + # builds API calls as /kiwi/api/v1/... — proxy these to the API container. + # Through Caddy the /kiwi prefix is stripped before reaching nginx, so this block + # is only active for direct-port access without Caddy in the path. + # Longer prefix (/kiwi/api/ = 10 chars) beats ^~/kiwi/ (6 chars) per nginx rules. + location /kiwi/api/ { + rewrite ^/kiwi(/api/.*)$ $1 break; + proxy_pass http://api:8512; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $http_x_real_ip; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; + proxy_set_header X-CF-Session $http_x_cf_session; + client_max_body_size 20m; + } + # When accessed directly (localhost:8515) instead of via Caddy (/kiwi path-strip), # Vite's /kiwi base URL means assets are requested at /kiwi/assets/... but stored # at /assets/... in nginx's root. Alias /kiwi/ → root so direct port access works. diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 8e8860b..ad1aa1c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -88,22 +88,22 @@
-
+
-
+
-
+
-
+
-
+
@@ -204,7 +204,7 @@