Enable HTTPS production deployment on Sinbad2 via Apache reverse proxy.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Axios from 'axios';
|
||||
import { API_BASE_URL } from '../config';
|
||||
import { isLoginPath, toAppPath } from './paths';
|
||||
|
||||
const api = Axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
@@ -28,8 +29,8 @@ api.interceptors.response.use(
|
||||
localStorage.removeItem('user');
|
||||
|
||||
// SOLUCIÓN: Solo recargamos y redirigimos si NO estamos ya en /login
|
||||
if (window.location.pathname !== '/login') {
|
||||
window.location.href = '/login';
|
||||
if (!isLoginPath(window.location.pathname)) {
|
||||
window.location.href = toAppPath('/login');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const normalizeBasePath = (value) => {
|
||||
if (!value || value === '/') {
|
||||
return '';
|
||||
}
|
||||
const withLeadingSlash = value.startsWith('/') ? value : `/${value}`;
|
||||
return withLeadingSlash.replace(/\/$/, '');
|
||||
};
|
||||
|
||||
export const APP_BASE_PATH = normalizeBasePath(import.meta.env.VITE_BASE_PATH);
|
||||
|
||||
export const toAppPath = (path) => {
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${APP_BASE_PATH}${normalizedPath}` || normalizedPath;
|
||||
};
|
||||
|
||||
export const isLoginPath = (pathname) => {
|
||||
const loginPath = toAppPath('/login');
|
||||
return pathname === loginPath || pathname === '/login';
|
||||
};
|
||||
Reference in New Issue
Block a user