Add legacy URL handling and update environment configurations
All checks were successful
Publish FaceAI Container / publish (push) Successful in 2m25s

This commit is contained in:
MaddoScientisto 2026-04-19 08:48:15 +02:00
commit f757f8af1d
11 changed files with 79 additions and 28 deletions

View file

@ -2,6 +2,7 @@ PORT=3001
FACEAI_FRONTEND_URL=http://localhost:5173 FACEAI_FRONTEND_URL=http://localhost:5173
FACEAI_PUBLIC_BASE_URL=http://localhost:3001 FACEAI_PUBLIC_BASE_URL=http://localhost:3001
FACEAI_LEGACY_RETURN_URL=http://localhost:3001/dev/legacy/return FACEAI_LEGACY_RETURN_URL=http://localhost:3001/dev/legacy/return
FACEAI_LEGACY_HOME_URL=http://localhost:8080/index.jsp
FACEAI_ENABLE_LOCAL_LEGACY_STATIC=1 FACEAI_ENABLE_LOCAL_LEGACY_STATIC=1
FACEAI_LOCAL_LEGACY_STATIC_ROOT=k:\various\regalamiunsorriso\www FACEAI_LOCAL_LEGACY_STATIC_ROOT=k:\various\regalamiunsorriso\www
FACEAI_SHARED_SECRET=change-me FACEAI_SHARED_SECRET=change-me

View file

@ -240,7 +240,7 @@ services:
- /mnt/storage/data/faceai/logs:/data/logs - /mnt/storage/data/faceai/logs:/data/logs
- /mnt/nas12/nas2/RUS:/data/pkl:ro - /mnt/nas12/nas2/RUS:/data/pkl:ro
ports: ports:
- "127.0.0.1:3001:3001" - "3001:3001"
healthcheck: healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3001/health | grep -q '\"ok\":true'"] test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3001/health | grep -q '\"ok\":true'"]
interval: 10s interval: 10s
@ -318,6 +318,7 @@ Public site settings:
| `FACEAI_FRONTEND_URL` | yes | `https://ai.regalamiunsorriso.it` | URL used when the legacy bridge redirects into the app | | `FACEAI_FRONTEND_URL` | yes | `https://ai.regalamiunsorriso.it` | URL used when the legacy bridge redirects into the app |
| `FACEAI_PUBLIC_BASE_URL` | yes | `https://ai.regalamiunsorriso.it` | public base URL used for local links and return flow generation | | `FACEAI_PUBLIC_BASE_URL` | yes | `https://ai.regalamiunsorriso.it` | public base URL used for local links and return flow generation |
| `FACEAI_LEGACY_RETURN_URL` | yes | `https://www.regalamiunsorriso.it/faceai_return.php` | legacy endpoint that receives the signed FaceAI result handoff | | `FACEAI_LEGACY_RETURN_URL` | yes | `https://www.regalamiunsorriso.it/faceai_return.php` | legacy endpoint that receives the signed FaceAI result handoff |
| `FACEAI_LEGACY_HOME_URL` | recommended | `https://www.regalamiunsorriso.it/` | fallback destination used when FaceAI has no valid session and needs to return the browser to the legacy site |
| `FACEAI_SESSION_COOKIE` | optional | `rus_faceai_session` | cookie name for the FaceAI session | | `FACEAI_SESSION_COOKIE` | optional | `rus_faceai_session` | cookie name for the FaceAI session |
| `FACEAI_UPLOAD_ROOT` | optional | `/data/runtime/uploads` | upload directory inside the shared runtime volume | | `FACEAI_UPLOAD_ROOT` | optional | `/data/runtime/uploads` | upload directory inside the shared runtime volume |
| `FACEAI_ENABLE_LOCAL_LEGACY_STATIC` | recommended | `0` | disables development-only static serving of local legacy assets | | `FACEAI_ENABLE_LOCAL_LEGACY_STATIC` | recommended | `0` | disables development-only static serving of local legacy assets |
@ -400,6 +401,7 @@ PORT=3001
FACEAI_FRONTEND_URL=http://localhost:5173 FACEAI_FRONTEND_URL=http://localhost:5173
FACEAI_PUBLIC_BASE_URL=http://localhost:3001 FACEAI_PUBLIC_BASE_URL=http://localhost:3001
FACEAI_LEGACY_RETURN_URL=http://localhost:3001/dev/legacy/return FACEAI_LEGACY_RETURN_URL=http://localhost:3001/dev/legacy/return
FACEAI_LEGACY_HOME_URL=http://localhost:8080/index.jsp
FACEAI_SHARED_SECRET=change-me FACEAI_SHARED_SECRET=change-me
FACEAI_SESSION_COOKIE=rus_faceai_session FACEAI_SESSION_COOKIE=rus_faceai_session
FACEAI_REDIS_URL=redis://redis:6379 FACEAI_REDIS_URL=redis://redis:6379
@ -417,6 +419,7 @@ In the provided Docker Compose stack, that wiring is already done with:
```text ```text
FACEAI_LEGACY_RETURN_URL=http://localhost:8080/faceai_return.php FACEAI_LEGACY_RETURN_URL=http://localhost:8080/faceai_return.php
FACEAI_LEGACY_HOME_URL=http://localhost:8080/index.jsp
``` ```
The log wiring is also already done in the checked-in Compose file with a host bind mount for `./logs:/data/logs`, so both the backend and the processor write persistent diagnostics into the workspace while also remaining visible through Docker and Portainer container logs. The log wiring is also already done in the checked-in Compose file with a host bind mount for `./logs:/data/logs`, so both the backend and the processor write persistent diagnostics into the workspace while also remaining visible through Docker and Portainer container logs.

View file

@ -3,13 +3,18 @@ import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
const defaultLocalLegacyRoot = path.resolve(__dirname, '../../../../www'); 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 = { export const config = {
port: Number(process.env.PORT || 3001), port: Number(process.env.PORT || 3001),
frontendUrl: process.env.FACEAI_FRONTEND_URL || 'http://localhost:5173', frontendUrl: envOrDefault('FACEAI_FRONTEND_URL', isProduction ? 'https://ai.regalamiunsorriso.it' : 'http://localhost:5173'),
publicBaseUrl: process.env.FACEAI_PUBLIC_BASE_URL || 'http://localhost:3001', publicBaseUrl: envOrDefault('FACEAI_PUBLIC_BASE_URL', isProduction ? 'https://ai.regalamiunsorriso.it' : 'http://localhost:3001'),
legacyReturnUrl: process.env.FACEAI_LEGACY_RETURN_URL || 'http://localhost:3001/dev/legacy/return', legacyReturnUrl: envOrDefault('FACEAI_LEGACY_RETURN_URL', isProduction ? 'https://www.regalamiunsorriso.it/faceai_return.php' : 'http://localhost:3001/dev/legacy/return'),
legacyHomeUrl: process.env.FACEAI_LEGACY_HOME_URL || 'http://localhost:8080/index.jsp', legacyHomeUrl: envOrDefault('FACEAI_LEGACY_HOME_URL', isProduction ? 'https://www.regalamiunsorriso.it/' : 'http://localhost:8080/index.jsp'),
pklRoot: process.env.FACEAI_PKL_ROOT || '/data/pkl', pklRoot: process.env.FACEAI_PKL_ROOT || '/data/pkl',
enableLocalLegacyStatic: process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC enableLocalLegacyStatic: process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC
? process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC === '1' ? process.env.FACEAI_ENABLE_LOCAL_LEGACY_STATIC === '1'

View file

@ -1,10 +1,16 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { legacyAsset } from '../legacyAssets.js'; import { legacyAsset } from '../legacyAssets.js';
import { legacyUrl } from '../legacyUrls.js';
const logoUrl = legacyAsset('/images/layout/regalami-un-sorriso-ets-640.png'); const logoUrl = legacyAsset('/images/layout/regalami-un-sorriso-ets-640.png');
const facebookUrl = legacyAsset('/images/FB-f-Logo__blue_29.png'); const facebookUrl = legacyAsset('/images/FB-f-Logo__blue_29.png');
const donateUrl = legacyAsset('/images/btn_donateCC_LG.gif'); 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); const isMenuOpen = ref(false);
function toggleMenu() { function toggleMenu() {
@ -21,7 +27,7 @@ function closeMenu() {
<a id="top"></a> <a id="top"></a>
<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-white fixed-top"> <nav class="navbar fixed-top navbar-expand-lg navbar-light bg-white fixed-top">
<div class="container"> <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" /> <img :src="logoUrl" alt="Regalami Un Sorriso ETS" width="100" />
</a> </a>
<button <button
@ -37,19 +43,19 @@ function closeMenu() {
<div :class="['collapse', 'navbar-collapse', { show: isMenuOpen }]" id="navbarResponsive"> <div :class="['collapse', 'navbar-collapse', { show: isMenuOpen }]" id="navbarResponsive">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"> <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>
<li class="nav-item"> <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>
<li class="nav-item"> <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>
<li class="nav-item"> <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>
<li class="nav-item"> <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" /> <img :src="donateUrl" border="0" alt="PayPal" />
</a> </a>
</li> </li>

View file

@ -1,4 +1,5 @@
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'; import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { legacyUrl } from '../legacyUrls.js';
const copy = { const copy = {
it: { it: {
@ -114,8 +115,8 @@ const knownServerMessages = {
'Choose a selfie before starting the search.': 'chooseSelfie' 'Choose a selfie before starting the search.': 'chooseSelfie'
}; };
const simulatorUrl = 'http://localhost:8080/faceai_simulator.php?raceId=101&lang=it'; const simulatorUrl = legacyUrl('/faceai_simulator.php?raceId=101&lang=it');
const legacyHomeUrl = 'http://localhost:8080/index.jsp'; const legacyHomeUrl = legacyUrl('/');
function isInvalidRaceAvailability(availability) { function isInvalidRaceAvailability(availability) {
return availability?.reasonCode === 'RACE_DIRECTORY_NOT_FOUND' || availability?.reasonCode === 'MISSING_RACE_STORAGE'; return availability?.reasonCode === 'RACE_DIRECTORY_NOT_FOUND' || availability?.reasonCode === 'MISSING_RACE_STORAGE';

View 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}`;
}

View file

@ -18,6 +18,7 @@ services:
FACEAI_FRONTEND_URL: http://localhost:3001 FACEAI_FRONTEND_URL: http://localhost:3001
FACEAI_PUBLIC_BASE_URL: http://localhost:3001 FACEAI_PUBLIC_BASE_URL: http://localhost:3001
FACEAI_LEGACY_RETURN_URL: http://localhost:8080/faceai_return.php FACEAI_LEGACY_RETURN_URL: http://localhost:8080/faceai_return.php
FACEAI_LEGACY_HOME_URL: http://localhost:8080/index.jsp
FACEAI_PKL_ROOT: /data/pkl FACEAI_PKL_ROOT: /data/pkl
FACEAI_ENABLE_LOCAL_LEGACY_STATIC: 1 FACEAI_ENABLE_LOCAL_LEGACY_STATIC: 1
FACEAI_LOCAL_LEGACY_STATIC_ROOT: /legacy-www FACEAI_LOCAL_LEGACY_STATIC_ROOT: /legacy-www

View file

@ -10,6 +10,7 @@ services:
FACEAI_FRONTEND_URL: https://ai.regalamiunsorriso.it FACEAI_FRONTEND_URL: https://ai.regalamiunsorriso.it
FACEAI_PUBLIC_BASE_URL: https://ai.regalamiunsorriso.it FACEAI_PUBLIC_BASE_URL: https://ai.regalamiunsorriso.it
FACEAI_LEGACY_RETURN_URL: https://www.regalamiunsorriso.it/faceai_return.php FACEAI_LEGACY_RETURN_URL: https://www.regalamiunsorriso.it/faceai_return.php
FACEAI_LEGACY_HOME_URL: https://www.regalamiunsorriso.it/
FACEAI_SHARED_SECRET: disagio-spaghetti-science-lol-boh FACEAI_SHARED_SECRET: disagio-spaghetti-science-lol-boh
FACEAI_SESSION_COOKIE: rus_faceai_session FACEAI_SESSION_COOKIE: rus_faceai_session
FACEAI_REDIS_URL: redis://redis:6379 FACEAI_REDIS_URL: redis://redis:6379

View file

@ -14,14 +14,16 @@ All files in this rollout are deployed from the current working tree.
## Updated Files ## Updated Files
- `www/mailMessage/noMorePic.html` - `www/faceai_config.php`
- `www/mailMessage/noMorePic.txt` - `www/faceai_handoff.php`
- `www/mailMessage/noMorePicCc.html` - `www/faceai_return.php`
- `www/mailMessage/noMorePicScad.html` - `www/fotoCR.jsp`
- `www/mailMessage/noMorePicScad.txt` - `www/fotoCR-en.jsp`
- `www/mailMessage/perScadereMsg.html`
- `www/mailMessage/userMsg_itCC - Copy.html` ## Excluded Files
- `www/mailMessage/userMsg_itCC.html`
- `www/faceai_simulator.php`
- `www/faceai_simulator_view.php`
## Remote Copy Target ## Remote Copy Target
@ -29,7 +31,7 @@ All files in this rollout are deployed from the current working tree.
- Remote host: `marco@83.149.164.4:410` - Remote host: `marco@83.149.164.4:410`
- Remote staging path: `/home/marco/regalamiunsorriso/incoming/www` - Remote staging path: `/home/marco/regalamiunsorriso/incoming/www`
- Remote live path: `/home/sites/regalamiunsorriso/www` - Remote live path: `/home/sites/regalamiunsorriso/www`
- Total files in this manifest: `8` - Total files in this manifest: `5`
## Transfer Method ## Transfer Method

View file

@ -52,10 +52,11 @@
</jsp:useBean> </jsp:useBean>
<% <%
String faceAiFeatureEnabledValue = System.getenv("FACEAI_FEATURE_ENABLED"); String faceAiFeatureEnabledValue = System.getenv("FACEAI_FEATURE_ENABLED");
if (faceAiFeatureEnabledValue == null) { if (faceAiFeatureEnabledValue == null || faceAiFeatureEnabledValue.trim().length() == 0) {
faceAiFeatureEnabledValue = System.getProperty("FACEAI_FEATURE_ENABLED", "0"); faceAiFeatureEnabledValue = System.getProperty("FACEAI_FEATURE_ENABLED", "1");
} }
boolean faceAiFeatureEnabled = "1".equals(faceAiFeatureEnabledValue) || "true".equalsIgnoreCase(faceAiFeatureEnabledValue) || "yes".equalsIgnoreCase(faceAiFeatureEnabledValue) || "on".equalsIgnoreCase(faceAiFeatureEnabledValue); String faceAiFeatureEnabledNormalized = faceAiFeatureEnabledValue != null ? faceAiFeatureEnabledValue.trim() : "";
boolean faceAiFeatureEnabled = !("0".equals(faceAiFeatureEnabledNormalized) || "false".equalsIgnoreCase(faceAiFeatureEnabledNormalized) || "no".equalsIgnoreCase(faceAiFeatureEnabledNormalized) || "off".equalsIgnoreCase(faceAiFeatureEnabledNormalized));
java.util.Date faceAiRaceDate = CR.getGara().getDataGaraInizio(); java.util.Date faceAiRaceDate = CR.getGara().getDataGaraInizio();
String faceAiRacePathBase = CR.getGara().getPathBase() != null ? CR.getGara().getPathBase().trim() : ""; String faceAiRacePathBase = CR.getGara().getPathBase() != null ? CR.getGara().getPathBase().trim() : "";
String faceAiRaceYear = ""; String faceAiRaceYear = "";

View file

@ -52,10 +52,11 @@
</jsp:useBean> </jsp:useBean>
<% <%
String faceAiFeatureEnabledValue = System.getenv("FACEAI_FEATURE_ENABLED"); String faceAiFeatureEnabledValue = System.getenv("FACEAI_FEATURE_ENABLED");
if (faceAiFeatureEnabledValue == null) { if (faceAiFeatureEnabledValue == null || faceAiFeatureEnabledValue.trim().length() == 0) {
faceAiFeatureEnabledValue = System.getProperty("FACEAI_FEATURE_ENABLED", "0"); faceAiFeatureEnabledValue = System.getProperty("FACEAI_FEATURE_ENABLED", "1");
} }
boolean faceAiFeatureEnabled = "1".equals(faceAiFeatureEnabledValue) || "true".equalsIgnoreCase(faceAiFeatureEnabledValue) || "yes".equalsIgnoreCase(faceAiFeatureEnabledValue) || "on".equalsIgnoreCase(faceAiFeatureEnabledValue); String faceAiFeatureEnabledNormalized = faceAiFeatureEnabledValue != null ? faceAiFeatureEnabledValue.trim() : "";
boolean faceAiFeatureEnabled = !("0".equals(faceAiFeatureEnabledNormalized) || "false".equalsIgnoreCase(faceAiFeatureEnabledNormalized) || "no".equalsIgnoreCase(faceAiFeatureEnabledNormalized) || "off".equalsIgnoreCase(faceAiFeatureEnabledNormalized));
java.util.Date faceAiRaceDate = CR.getGara().getDataGaraInizio(); java.util.Date faceAiRaceDate = CR.getGara().getDataGaraInizio();
String faceAiRacePathBase = CR.getGara().getPathBase() != null ? CR.getGara().getPathBase().trim() : ""; String faceAiRacePathBase = CR.getGara().getPathBase() != null ? CR.getGara().getPathBase().trim() : "";
String faceAiRaceYear = ""; String faceAiRaceYear = "";