Files
NeveTimePanel/frontend/src/config.js
arkonsadter 05b8efd0f2
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed
Prepare hosting deployment and Drone image builds
2026-03-18 15:26:18 +06:00

28 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Автоматически определяем API URL
const getApiUrl = () => {
// Если переменная задана даже пустой строкой, используем её как явный override.
// Пустая строка = same-origin (/api через nginx proxy).
if (Object.prototype.hasOwnProperty.call(import.meta.env, 'VITE_API_URL')) {
const value = import.meta.env.VITE_API_URL || '';
return value.replace(/\/$/, '');
}
// Иначе используем текущий хост с портом 4546
const protocol = window.location.protocol;
const hostname = window.location.hostname;
// Если localhost, используем localhost:4546
if (hostname === 'localhost' || hostname === '127.0.0.1') {
return `${protocol}//localhost:4546`;
}
// Для удаленного доступа используем IP:4546
return `${protocol}//${hostname}:4546`;
};
export const API_URL = getApiUrl();
export const WS_URL = API_URL.replace('http', 'ws');
console.log('API URL:', API_URL);
console.log('WS URL:', WS_URL);