1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

тестd32123322в

This commit is contained in:
MoonTestUse1
2025-01-05 01:00:04 +06:00
parent 540e3e69db
commit 7399092e69
4 changed files with 14 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ services:
ports: ports:
- "80:80" - "80:80"
volumes: volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on: depends_on:
- frontend - frontend
- backend - backend
@@ -19,6 +19,10 @@ services:
dockerfile: docker/frontend/Dockerfile dockerfile: docker/frontend/Dockerfile
volumes: volumes:
- ./frontend:/app - ./frontend:/app
- /app/node_modules
environment:
- NODE_ENV=development
- VITE_API_URL=/api
depends_on: depends_on:
- backend - backend

View File

@@ -11,7 +11,6 @@ RUN rm -rf node_modules package-lock.json
# Устанавливаем зависимости # Устанавливаем зависимости
RUN npm install RUN npm install
RUN npm install axios@1.6.2
# Копируем исходный код # Копируем исходный код
COPY frontend/ . COPY frontend/ .
@@ -21,4 +20,5 @@ EXPOSE 5173
# Запускаем Vite сервер # Запускаем Vite сервер
ENV HOST=0.0.0.0 ENV HOST=0.0.0.0
ENV NODE_ENV=development
CMD ["npm", "run", "dev"] CMD ["npm", "run", "dev"]

View File

@@ -1,4 +1,4 @@
import axios, { InternalAxiosRequestConfig } from 'axios' import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: '/api', baseURL: '/api',
@@ -10,22 +10,22 @@ const axiosInstance = axios.create({
// Добавляем перехватчик для добавления токена // Добавляем перехватчик для добавления токена
axiosInstance.interceptors.request.use( axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig) => { (config: AxiosRequestConfig) => {
const token = localStorage.getItem('token') const token = localStorage.getItem('token')
if (token) { if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}` config.headers.Authorization = `Bearer ${token}`
} }
return config return config
}, },
(error) => { (error: AxiosError) => {
return Promise.reject(error) return Promise.reject(error)
} }
) )
// Добавляем перехватчик для обработки ошибок // Добавляем перехватчик для обработки ошибок
axiosInstance.interceptors.response.use( axiosInstance.interceptors.response.use(
(response) => response, (response: AxiosResponse) => response,
(error) => { (error: AxiosError) => {
if (error.response?.status === 401) { if (error.response?.status === 401) {
localStorage.removeItem('token') localStorage.removeItem('token')
window.location.href = '/admin/login' window.location.href = '/admin/login'

View File

@@ -24,7 +24,8 @@ export default defineConfig({
proxy: { proxy: {
'/api': { '/api': {
target: 'http://backend:8000', target: 'http://backend:8000',
changeOrigin: true changeOrigin: true,
secure: false
} }
} }
} }