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
|
|
@ -3,13 +3,18 @@ import { fileURLToPath } from 'node:url';
|
|||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const defaultLocalLegacyRoot = path.resolve(__dirname, '../../../../www');
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
function envOrDefault(name, defaultValue) {
|
||||
return process.env[name] || defaultValue;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
port: Number(process.env.PORT || 3001),
|
||||
frontendUrl: process.env.FACEAI_FRONTEND_URL || 'http://localhost:5173',
|
||||
publicBaseUrl: process.env.FACEAI_PUBLIC_BASE_URL || 'http://localhost:3001',
|
||||
legacyReturnUrl: process.env.FACEAI_LEGACY_RETURN_URL || 'http://localhost:3001/dev/legacy/return',
|
||||
legacyHomeUrl: process.env.FACEAI_LEGACY_HOME_URL || 'http://localhost:8080/index.jsp',
|
||||
frontendUrl: envOrDefault('FACEAI_FRONTEND_URL', isProduction ? 'https://ai.regalamiunsorriso.it' : 'http://localhost:5173'),
|
||||
publicBaseUrl: envOrDefault('FACEAI_PUBLIC_BASE_URL', isProduction ? 'https://ai.regalamiunsorriso.it' : 'http://localhost:3001'),
|
||||
legacyReturnUrl: envOrDefault('FACEAI_LEGACY_RETURN_URL', isProduction ? 'https://www.regalamiunsorriso.it/faceai_return.php' : 'http://localhost:3001/dev/legacy/return'),
|
||||
legacyHomeUrl: envOrDefault('FACEAI_LEGACY_HOME_URL', isProduction ? 'https://www.regalamiunsorriso.it/' : 'http://localhost:8080/index.jsp'),
|
||||
pklRoot: process.env.FACEAI_PKL_ROOT || '/data/pkl',
|
||||
enableLocalLegacyStatic: process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC
|
||||
? process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC === '1'
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { legacyAsset } from '../legacyAssets.js';
|
||||
import { legacyUrl } from '../legacyUrls.js';
|
||||
|
||||
const logoUrl = legacyAsset('/images/layout/regalami-un-sorriso-ets-640.png');
|
||||
const facebookUrl = legacyAsset('/images/FB-f-Logo__blue_29.png');
|
||||
const donateUrl = legacyAsset('/images/btn_donateCC_LG.gif');
|
||||
const legacyHomeUrl = legacyUrl('/');
|
||||
const associationUrl = legacyUrl('/associazione.jsp');
|
||||
const photoUrl = legacyUrl('/gallery2.php');
|
||||
const archiveUrl = legacyUrl('/gallery2.php');
|
||||
const donatePageUrl = legacyUrl('/dettaglio_clienti-it.html');
|
||||
const isMenuOpen = ref(false);
|
||||
|
||||
function toggleMenu() {
|
||||
|
|
@ -21,7 +27,7 @@ function closeMenu() {
|
|||
<a id="top"></a>
|
||||
<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-white fixed-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="http://localhost:8080/faceai_simulator.php?raceId=101&lang=it">
|
||||
<a class="navbar-brand" :href="legacyHomeUrl">
|
||||
<img :src="logoUrl" alt="Regalami Un Sorriso ETS" width="100" />
|
||||
</a>
|
||||
<button
|
||||
|
|
@ -37,19 +43,19 @@ function closeMenu() {
|
|||
<div :class="['collapse', 'navbar-collapse', { show: isMenuOpen }]" id="navbarResponsive">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="http://localhost:8080/index.jsp" @click="closeMenu">Home</a>
|
||||
<a class="nav-link" :href="legacyHomeUrl" @click="closeMenu">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="http://localhost:8080/associazione.jsp" @click="closeMenu">Associazione</a>
|
||||
<a class="nav-link" :href="associationUrl" @click="closeMenu">Associazione</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="http://localhost:8080/faceai_simulator.php?raceId=101&lang=it" @click="closeMenu">Foto</a>
|
||||
<a class="nav-link active" :href="photoUrl" @click="closeMenu">Foto</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn btn-sm btn-warning" href="http://localhost:8080/gallery2.php" @click="closeMenu">Archivio</a>
|
||||
<a class="nav-link btn btn-sm btn-warning" :href="archiveUrl" @click="closeMenu">Archivio</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="http://localhost:8080/dettaglio_clienti-it.html" @click="closeMenu">
|
||||
<a :href="donatePageUrl" @click="closeMenu">
|
||||
<img :src="donateUrl" border="0" alt="PayPal" />
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { legacyUrl } from '../legacyUrls.js';
|
||||
|
||||
const copy = {
|
||||
it: {
|
||||
|
|
@ -114,8 +115,8 @@ const knownServerMessages = {
|
|||
'Choose a selfie before starting the search.': 'chooseSelfie'
|
||||
};
|
||||
|
||||
const simulatorUrl = 'http://localhost:8080/faceai_simulator.php?raceId=101&lang=it';
|
||||
const legacyHomeUrl = 'http://localhost:8080/index.jsp';
|
||||
const simulatorUrl = legacyUrl('/faceai_simulator.php?raceId=101&lang=it');
|
||||
const legacyHomeUrl = legacyUrl('/');
|
||||
|
||||
function isInvalidRaceAvailability(availability) {
|
||||
return availability?.reasonCode === 'RACE_DIRECTORY_NOT_FOUND' || availability?.reasonCode === 'MISSING_RACE_STORAGE';
|
||||
|
|
|
|||
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