fix путей

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-03-12 00:09:36 +03:00
parent 1fcc5ed70d
commit dd589790c2
12 changed files with 1997 additions and 529 deletions

View File

@@ -2,15 +2,25 @@
$(document).ready(function() {
// Функция для получения базового пути API
const getApiPath = () => {
// Извлекаем базовый путь из URL страницы
const pathParts = window.location.pathname.split('/');
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Проверяем, содержит ли путь /ms/ (продакшн на dev.bro-js.ru)
const pathname = window.location.pathname;
const isMsPath = pathname.includes('/ms/questioneer');
// Путь до корня приложения
return pathParts.join('/') + '/api';
if (isMsPath) {
// Для продакшна: если в пути есть /ms/, то API доступно по /ms/questioneer/api
return '/ms/questioneer/api';
} else {
// Для локальной разработки: используем обычный путь
// Извлекаем базовый путь из URL страницы
const pathParts = pathname.split('/');
// Если последний сегмент пустой (из-за /) - удаляем его
if (pathParts[pathParts.length - 1] === '') {
pathParts.pop();
}
// Путь до корня приложения
return pathParts.join('/') + '/api';
}
};
// Функция для загрузки списка опросов
@@ -40,9 +50,18 @@ $(document).ready(function() {
}
// Получаем базовый путь (для работы и с /questioneer, и с /ms/questioneer)
const basePath = window.location.pathname.endsWith('/')
? window.location.pathname
: window.location.pathname + '/';
const basePath = (() => {
const pathname = window.location.pathname;
const isMsPath = pathname.includes('/ms/questioneer');
if (isMsPath) {
// Для продакшна: нужно использовать /ms/questioneer/ для ссылок
return '/ms/questioneer/';
} else {
// Для локальной разработки: используем текущий путь
return pathname.endsWith('/') ? pathname : pathname + '/';
}
})();
const questionnairesHTML = questionnaires.map(q => `
<div class="questionnaire-item">