From 33eb5fbdb293efd06c38ba7946e56c111ea04847 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Wed, 22 Apr 2026 10:31:57 +0200 Subject: [PATCH] fix: improve imageUrl handling in Recipe model to avoid null or empty values --- flutter/Caddyfile | 5 +++++ flutter/lib/features/recipes/domain/recipe.dart | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/flutter/Caddyfile b/flutter/Caddyfile index 03a88ca3..7657372a 100644 --- a/flutter/Caddyfile +++ b/flutter/Caddyfile @@ -1,6 +1,11 @@ :{$PORT:5000} { root * /usr/share/caddy + # Recipe images are stored in a shared volume and served by the Next service. + handle /images/* { + reverse_proxy recipe-frontend:3000 + } + # Proxy API calls to backend service on the internal Docker network. handle /api/* { reverse_proxy recipe-api:8080 diff --git a/flutter/lib/features/recipes/domain/recipe.dart b/flutter/lib/features/recipes/domain/recipe.dart index cb6ff630..10964338 100644 --- a/flutter/lib/features/recipes/domain/recipe.dart +++ b/flutter/lib/features/recipes/domain/recipe.dart @@ -26,12 +26,16 @@ class Recipe { final dynamic rawImageUrl = json['imageUrl']; final dynamic rawServings = json['servings']; final rawIngredients = json['ingredients'] as List? ?? []; + final normalizedImageUrl = rawImageUrl?.toString().trim(); return Recipe( id: rawId is num ? rawId.toInt() : int.parse(rawId.toString()), title: (rawTitle ?? '').toString(), description: rawDescription == null ? null : rawDescription.toString(), - imageUrl: rawImageUrl == null ? null : rawImageUrl.toString(), + imageUrl: + (normalizedImageUrl == null || normalizedImageUrl.isEmpty) + ? null + : normalizedImageUrl, servings: rawServings == null ? null : (rawServings is num