diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 0000000..ead6541 --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1,3 @@ +# Backend API URL. По умолчанию "/api/v1" (через nginx proxy). +# Для локальной разработки: "http://localhost:8080/api/v1" +VITE_API_BASE_URL=/api/v1 diff --git a/frontend/dockerfile b/frontend/dockerfile index 0e50b89..9f59760 100644 --- a/frontend/dockerfile +++ b/frontend/dockerfile @@ -2,6 +2,9 @@ FROM node:25-alpine3.23 AS builder WORKDIR /app +ARG VITE_API_BASE_URL=/api/v1 +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} + COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 69eb365..9368384 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -9,15 +9,13 @@ server { location / { try_files $uri $uri/ /index.html; } + location /api/ { - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; + proxy_pass http://backend:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_cache_bypass $http_upgrade; } diff --git a/frontend/src/shared/api/axios.instance.ts b/frontend/src/shared/api/axios.instance.ts index e5381c3..f8e4e88 100644 --- a/frontend/src/shared/api/axios.instance.ts +++ b/frontend/src/shared/api/axios.instance.ts @@ -16,7 +16,7 @@ class ApiClient { constructor() { this.axiosInstance = axios.create({ - baseURL: "http://213.165.213.170:8080/api/v1", + baseURL: import.meta.env.VITE_API_BASE_URL || "/api/v1", timeout: 10000, headers: { "Content-Type": "application/json",