Fix production web API routing
This commit is contained in:
@@ -5,8 +5,9 @@ import {
|
||||
getAccessToken,
|
||||
setAccessToken,
|
||||
} from '../utils/session';
|
||||
import { resolveApiUrl } from '../config/api';
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000';
|
||||
const API_URL = resolveApiUrl();
|
||||
|
||||
const client = axios.create({
|
||||
baseURL: API_URL,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import { resolveApiUrl } from '../config/api';
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000';
|
||||
const API_URL = resolveApiUrl();
|
||||
|
||||
export const verifySignature = (code) => axios.get(`${API_URL}/signatures/verify/${code}`);
|
||||
export const getLegalTemplates = () => axios.get(`${API_URL}/legal/templates`);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
const normalize = (value) => String(value || '').replace(/\/$/, '');
|
||||
|
||||
export const resolveApiUrl = () => {
|
||||
if (typeof window !== 'undefined' && window.location?.hostname === 'sign.linkedcorp.net') {
|
||||
return '/api';
|
||||
}
|
||||
|
||||
return normalize(import.meta.env.VITE_API_URL || 'http://192.168.222.40:4000');
|
||||
};
|
||||
|
||||
export const resolveAndroidApkUrl = () => {
|
||||
if (typeof window !== 'undefined' && window.location?.hostname === 'sign.linkedcorp.net') {
|
||||
return '/api/downloads/android-apk';
|
||||
}
|
||||
|
||||
return `${resolveApiUrl()}/downloads/android-apk`;
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import { useAuth } from '../../contexts/AuthContext';
|
||||
import { Download, PenTool } from 'lucide-react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { SESSION_EXPIRED_MESSAGE, translateApiError } from '../../utils/session';
|
||||
import { resolveAndroidApkUrl } from '../../config/api';
|
||||
import packageInfo from '../../../package.json';
|
||||
|
||||
export default function LoginPage() {
|
||||
@@ -12,8 +13,7 @@ export default function LoginPage() {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [form, setForm] = useState({ email: '', password: '' });
|
||||
const [loading, setLoading] = useState(false);
|
||||
const apiBaseUrl = (import.meta.env.VITE_API_URL || 'http://localhost:4000').replace(/\/$/, '');
|
||||
const androidApkUrl = `${apiBaseUrl}/downloads/android-apk`;
|
||||
const androidApkUrl = resolveAndroidApkUrl();
|
||||
const showAndroidDownload = useMemo(() => {
|
||||
if (typeof navigator === 'undefined') return false;
|
||||
return /Android/i.test(navigator.userAgent || '');
|
||||
|
||||
Reference in New Issue
Block a user