From 10656615d14a5671f2ce1c4d33165c859abad547 Mon Sep 17 00:00:00 2001 From: Deep Koluguri Date: Tue, 30 Jun 2026 21:27:24 -0400 Subject: [PATCH] fix: resolve hardcoded localhost API endpoints in frontend --- newspaper-extractor/frontend/next.config.ts | 4 +++- newspaper-extractor/frontend/src/app/dashboard/page.tsx | 4 ++-- newspaper-extractor/frontend/src/components/ArticleCard.tsx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/newspaper-extractor/frontend/next.config.ts b/newspaper-extractor/frontend/next.config.ts index 9bcda51..ef40710 100644 --- a/newspaper-extractor/frontend/next.config.ts +++ b/newspaper-extractor/frontend/next.config.ts @@ -1,11 +1,13 @@ import type { NextConfig } from "next"; +const BACKEND_URL = process.env.BACKEND_URL || 'http://newspaper-backend.ai-agents.svc.cluster.local:8000'; + const nextConfig: NextConfig = { async rewrites() { return [ { source: '/api/:path*', - destination: 'http://backend:8000/api/:path*', + destination: `${BACKEND_URL}/api/:path*`, }, ]; }, diff --git a/newspaper-extractor/frontend/src/app/dashboard/page.tsx b/newspaper-extractor/frontend/src/app/dashboard/page.tsx index 53a42de..e33bfb7 100644 --- a/newspaper-extractor/frontend/src/app/dashboard/page.tsx +++ b/newspaper-extractor/frontend/src/app/dashboard/page.tsx @@ -10,14 +10,14 @@ export default function Dashboard() { fd.append("file", file); fd.append("newspaper", "The Hindu"); fd.append("date", new Date().toISOString().slice(0,10)); - const r = await fetch("http://localhost:8000/api/upload", {method:"POST", body:fd}); + const r = await fetch("/api/upload", {method:"POST", body:fd}); const j = await r.json(); setTask(j.task_id); poll(j.task_id); } async function poll(id: string) { - const r = await fetch(`http://localhost:8000/api/status/${id}`); + const r = await fetch(`/api/status/${id}`); const j = await r.json(); setStatus(j.state); if (j.state !== "SUCCESS" && j.state !== "FAILURE") diff --git a/newspaper-extractor/frontend/src/components/ArticleCard.tsx b/newspaper-extractor/frontend/src/components/ArticleCard.tsx index de5148e..beb883b 100644 --- a/newspaper-extractor/frontend/src/components/ArticleCard.tsx +++ b/newspaper-extractor/frontend/src/components/ArticleCard.tsx @@ -18,7 +18,7 @@ export function ArticleCard({ article }: ArticleCardProps) { // The path is internal to docker like /data/storage/cropped_XYZ.jpg // Assuming the backend mounts /data/storage at /api/images const imageUrl = article.image_path - ? `http://localhost:8000/api/images/${article.image_path.split('/').pop()}` + ? `/api/images/${article.image_path.split('/').pop()}` : null; return (