feat: receive and serve product images pushed from local sites
New POST /api/menu/sync-image (site-authenticated) accepts a product's
image file, stores it under /app/data/product_images keyed by
(site, product_id), and skips the write entirely if the uploaded
content hash matches what's already stored. GET /api/menu/{site_slug}
now injects the cloud-hosted image URL into each product that has no
manual digital_image_url override — replacing the local-only image_url
from the snapshot, which was never reachable from the public internet.
Also fixes the menu-app resolving product image URLs as bare relative
paths instead of prefixing them with the cloud API origin (same class
of bug as the earlier header-image fix).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,13 @@ const I18N = {
|
||||
},
|
||||
}
|
||||
|
||||
// Resolve a possibly-relative path (e.g. "/static/product_images/x.jpg") against
|
||||
// the cloud API origin. Absolute URLs (manager-set external overrides) pass through untouched.
|
||||
function resolveImageUrl(url) {
|
||||
if (!url) return null
|
||||
return /^https?:\/\//i.test(url) ? url : `${CLOUD_URL}${url}`
|
||||
}
|
||||
|
||||
// ── Normalise a backend product to the shape the UI expects ──────────────────
|
||||
function normaliseProduct(p, catId) {
|
||||
return {
|
||||
@@ -68,7 +75,7 @@ function normaliseProduct(p, catId) {
|
||||
allergens: p.allergens || [],
|
||||
ingredients: p.ingredients || null,
|
||||
discountPct: p.digital_discount || p.discountPct || 0,
|
||||
image_url: p.digital_image_url || p.image_url || null,
|
||||
image_url: resolveImageUrl(p.digital_image_url || p.image_url || null),
|
||||
digital_available: p.digital_available !== false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user