diff --git a/frontend/application/lib/services/productService.ts b/frontend/application/lib/services/productService.ts index 24640df2..ce9b75a6 100644 --- a/frontend/application/lib/services/productService.ts +++ b/frontend/application/lib/services/productService.ts @@ -273,8 +273,17 @@ export class ProductService { } const response = await api.get(`/products/${slug}`); return this.mapBackendToFrontend(response.data); - } catch (error) { - console.error(`[ProductService] Failed to fetch product ${slug}:`, error); + } catch (error: any) { + // Differentiate 404 (legitimate not found) from network/5xx server failure + const status = error?.response?.status || (String(error?.message).includes('404') ? 404 : null); + if (status === 404) { + return null; + } + console.error(`[ProductService] Upstream error fetching product ${slug}:`, error); + // Re-throw upstream server errors so Next.js ErrorBoundary renders retryable state instead of fake 404 + if (typeof window === 'undefined') { + throw error; + } return null; } }