mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
тестd32123322в
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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"]
|
@@ -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'
|
||||
|
@@ -24,7 +24,8 @@ export default defineConfig({
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://backend:8000',
|
||||
changeOrigin: true
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user