fix: resolve hardcoded localhost API endpoints in frontend
Build Newspaper Extractor Frontend / build-newspaper-frontend (push) Successful in 6m26s Details
Build Newspaper Extractor Backend / build-newspaper-backend (push) Failing after 14m41s Details

This commit is contained in:
Deep Koluguri 2026-06-30 21:27:24 -04:00
parent 6d08feb709
commit 10656615d1
3 changed files with 6 additions and 4 deletions

View File

@ -1,11 +1,13 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const BACKEND_URL = process.env.BACKEND_URL || 'http://newspaper-backend.ai-agents.svc.cluster.local:8000';
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
async rewrites() { async rewrites() {
return [ return [
{ {
source: '/api/:path*', source: '/api/:path*',
destination: 'http://backend:8000/api/:path*', destination: `${BACKEND_URL}/api/:path*`,
}, },
]; ];
}, },

View File

@ -10,14 +10,14 @@ export default function Dashboard() {
fd.append("file", file); fd.append("file", file);
fd.append("newspaper", "The Hindu"); fd.append("newspaper", "The Hindu");
fd.append("date", new Date().toISOString().slice(0,10)); 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(); const j = await r.json();
setTask(j.task_id); setTask(j.task_id);
poll(j.task_id); poll(j.task_id);
} }
async function poll(id: string) { 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(); const j = await r.json();
setStatus(j.state); setStatus(j.state);
if (j.state !== "SUCCESS" && j.state !== "FAILURE") if (j.state !== "SUCCESS" && j.state !== "FAILURE")

View File

@ -18,7 +18,7 @@ export function ArticleCard({ article }: ArticleCardProps) {
// The path is internal to docker like /data/storage/cropped_XYZ.jpg // The path is internal to docker like /data/storage/cropped_XYZ.jpg
// Assuming the backend mounts /data/storage at /api/images // Assuming the backend mounts /data/storage at /api/images
const imageUrl = article.image_path const imageUrl = article.image_path
? `http://localhost:8000/api/images/${article.image_path.split('/').pop()}` ? `/api/images/${article.image_path.split('/').pop()}`
: null; : null;
return ( return (