Enable HTTPS production deployment on Sinbad2 via Apache reverse proxy.
This commit is contained in:
@@ -89,7 +89,7 @@ export default function Header() {
|
||||
className="flex items-center gap-3 whitespace-nowrap transition-opacity hover:opacity-80"
|
||||
>
|
||||
<img
|
||||
src="/favicon.svg"
|
||||
src={`${import.meta.env.BASE_URL}favicon.svg`}
|
||||
alt="Deck of Cards Logo"
|
||||
className="h-10 w-10 rounded-xl object-contain shadow-sm"
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export const API_BASE_URL = import.meta.env.VITE_API_URL;
|
||||
import { APP_BASE_PATH } from './lib/paths';
|
||||
|
||||
const configuredApiUrl = import.meta.env.VITE_API_URL;
|
||||
export const API_BASE_URL = configuredApiUrl || (APP_BASE_PATH ? `${APP_BASE_PATH}/api` : '/api');
|
||||
|
||||
export const CHART_COLORS = [
|
||||
'#ef4444', '#f59e0b', '#10b981', '#3b82f6',
|
||||
|
||||
@@ -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';
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { APP_BASE_PATH } from '../lib/paths';
|
||||
import MainLayout from '../components/layout/MainLayout';
|
||||
import DocEditor from '../pages/DocEditor';
|
||||
import Login from '../pages/Login';
|
||||
@@ -18,7 +19,7 @@ function ProtectedHistoryRoute() {
|
||||
|
||||
export default function AppRouter() {
|
||||
return (
|
||||
<Router>
|
||||
<Router basename={APP_BASE_PATH || undefined}>
|
||||
<MainLayout>
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="/editor" replace />} />
|
||||
|
||||
Reference in New Issue
Block a user