fix: resolve hardcoded localhost API endpoints in frontend
This commit is contained in:
parent
6d08feb709
commit
10656615d1
|
|
@ -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*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Reference in New Issue