diff --git a/app/tandoor.py b/app/tandoor.py index 116694b..40d4570 100644 --- a/app/tandoor.py +++ b/app/tandoor.py @@ -36,6 +36,14 @@ class TandoorClient: "Accept": "application/json", }) + def _public_image_url(self, url: str) -> str: + """Rewrite an internal API image URL to the public base URL.""" + if not url: + return "" + if self.api_url != self.base_url and url.startswith(self.api_url): + return self.base_url + url[len(self.api_url):] + return url + # ------------------------------------------------------------------ # Public # ------------------------------------------------------------------ @@ -104,7 +112,7 @@ class TandoorClient: items.append({ "id": item["id"], "name": item.get("name", ""), - "image": item.get("image") or "", + "image": self._public_image_url(item.get("image") or ""), "tags": [k.get("name", "") for k in item.get("keywords", []) if k.get("name")], "url": f"{self.base_url}/view/recipe/{item['id']}", }) @@ -161,7 +169,7 @@ class TandoorClient: return { "title": data.get("name", ""), "description": data.get("description", ""), - "image_url": data.get("image") or "", + "image_url": self._public_image_url(data.get("image") or ""), "ingredients": ingredients, "instructions": instructions, "tags": tags,