Add legacy URL handling and update environment configurations
This commit is contained in:
parent
19f0d65896
commit
9f56dfba1d
11 changed files with 79 additions and 28 deletions
29
faceai/apps/frontend/src/legacyUrls.js
Normal file
29
faceai/apps/frontend/src/legacyUrls.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
const localHostnames = new Set(['localhost', '127.0.0.1', '::1']);
|
||||
|
||||
function trimTrailingSlash(value) {
|
||||
return String(value || '').replace(/\/$/, '');
|
||||
}
|
||||
|
||||
function currentHostname() {
|
||||
if (typeof window === 'undefined' || !window.location || !window.location.hostname) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return window.location.hostname.toLowerCase();
|
||||
}
|
||||
|
||||
export function getLegacyBaseUrl() {
|
||||
const configuredBaseUrl = trimTrailingSlash(import.meta.env.VITE_LEGACY_BASE_URL || '');
|
||||
if (configuredBaseUrl) {
|
||||
return configuredBaseUrl;
|
||||
}
|
||||
|
||||
return localHostnames.has(currentHostname())
|
||||
? 'http://localhost:8080'
|
||||
: 'https://www.regalamiunsorriso.it';
|
||||
}
|
||||
|
||||
export function legacyUrl(path = '/') {
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${getLegacyBaseUrl()}${normalizedPath}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue