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

View File

@@ -11,7 +11,6 @@ RUN rm -rf node_modules package-lock.json
# Устанавливаем зависимости
RUN npm install
RUN npm install axios@1.6.2
# Копируем исходный код
COPY frontend/ .
@@ -21,4 +20,5 @@ EXPOSE 5173
# Запускаем Vite сервер
ENV HOST=0.0.0.0
ENV NODE_ENV=development
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({
baseURL: '/api',
@@ -10,22 +10,22 @@ const axiosInstance = axios.create({
// Добавляем перехватчик для добавления токена
axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
(config: AxiosRequestConfig) => {
const token = localStorage.getItem('token')
if (token) {
if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}`
}
return config
},
(error) => {
(error: AxiosError) => {
return Promise.reject(error)
}
)
// Добавляем перехватчик для обработки ошибок
axiosInstance.interceptors.response.use(
(response) => response,
(error) => {
(response: AxiosResponse) => response,
(error: AxiosError) => {
if (error.response?.status === 401) {
localStorage.removeItem('token')
window.location.href = '/admin/login'

View File

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