ваше сообщение коммита

This commit is contained in:
2025-04-21 10:40:57 +03:00
parent f371521511
commit 16c3534239
22 changed files with 637 additions and 84 deletions

View File

@@ -1,8 +1,18 @@
import axios from 'axios';
// Определяем baseURL в зависимости от окружения
const getBaseUrl = () => {
// В браузере используем localhost
if (typeof window !== 'undefined' && window.location.hostname === 'localhost') {
return 'http://localhost:8000';
}
// В других случаях используем переменную окружения
return import.meta.env.VITE_API_URL || '';
};
// Создаем экземпляр axios с базовым URL
const api = axios.create({
baseURL: import.meta.env.VITE_API_URL || '',
baseURL: getBaseUrl(),
withCredentials: true,
headers: {
'Content-Type': 'application/json'

View File

@@ -7,7 +7,9 @@ import router from './router';
import axios from 'axios';
// Настройка axios
axios.defaults.baseURL = import.meta.env.VITE_API_URL || '';
// В Docker контейнере localhost:8000 не работает, поэтому используем явное значение
const apiUrl = window.location.hostname === 'localhost' ? 'http://localhost:8000' : import.meta.env.VITE_API_URL;
axios.defaults.baseURL = apiUrl;
axios.defaults.withCredentials = true;
// Создаем и монтируем приложение Vue
@@ -25,7 +27,7 @@ app.use(router);
// ]).catch(err => console.error('Failed to load API mocks:', err));
// }
console.log('API URL:', import.meta.env.VITE_API_URL);
console.log('API URL:', apiUrl);
console.log('main.js: Starting application with router');
app.mount('#app');