From 67aa30618f1e91af86fc162afb5ca0d3ce5167c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4?= Date: Fri, 17 Jul 2026 05:59:12 -0400 Subject: [PATCH 1/9] add env in front, fix build front, add API_URL in page tsx --- frontend/.env.production | 3 +++ frontend/src/app/page.tsx | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 frontend/.env.production diff --git a/frontend/.env.production b/frontend/.env.production new file mode 100644 index 00000000..a4ca0c2c --- /dev/null +++ b/frontend/.env.production @@ -0,0 +1,3 @@ +# URL бэкенда для клиентских запросов (fetch в src/app/page.tsx). +# Префикс NEXT_PUBLIC_ обязателен — иначе Next.js не пробросит переменную в браузерный код. +NEXT_PUBLIC_API_URL=http://localhost:8000 diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 8f420e2e..e7200e4d 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -15,6 +15,8 @@ import { Table, } from "react-bootstrap"; +const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000"; + type FileItem = { id: string; title: string; @@ -102,8 +104,8 @@ export default function Page() { try { const [filesResponse, alertsResponse] = await Promise.all([ - fetch(`http://localhost:8000/files`, { cache: "no-store" }), - fetch(`http://localhost:8000/alerts`, { cache: "no-store" }), + fetch(`${API_URL}/files`, { cache: "no-store" }), + fetch(`${API_URL}/alerts`, { cache: "no-store" }), ]); if (!filesResponse.ok || !alertsResponse.ok) { @@ -144,7 +146,7 @@ export default function Page() { formData.append("file", selectedFile); try { - const response = await fetch(`http://localhost:8000/files`, { + const response = await fetch(`${API_URL}/files`, { method: "POST", body: formData, }); @@ -258,7 +260,7 @@ export default function Page() {