diff --git a/faceai/.env.example b/faceai/.env.example index 6b185e47..3944ada9 100644 --- a/faceai/.env.example +++ b/faceai/.env.example @@ -2,6 +2,7 @@ PORT=3001 FACEAI_FRONTEND_URL=http://localhost:5173 FACEAI_PUBLIC_BASE_URL=http://localhost:3001 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_LOCAL_LEGACY_STATIC_ROOT=k:\various\regalamiunsorriso\www FACEAI_SHARED_SECRET=change-me diff --git a/faceai/README.md b/faceai/README.md index bcb04f06..a808a015 100644 --- a/faceai/README.md +++ b/faceai/README.md @@ -240,7 +240,7 @@ services: - /mnt/storage/data/faceai/logs:/data/logs - /mnt/nas12/nas2/RUS:/data/pkl:ro ports: - - "127.0.0.1:3001:3001" + - "3001:3001" healthcheck: test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3001/health | grep -q '\"ok\":true'"] 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_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_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_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 | @@ -400,6 +401,7 @@ PORT=3001 FACEAI_FRONTEND_URL=http://localhost:5173 FACEAI_PUBLIC_BASE_URL=http://localhost:3001 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_SESSION_COOKIE=rus_faceai_session FACEAI_REDIS_URL=redis://redis:6379 @@ -417,6 +419,7 @@ In the provided Docker Compose stack, that wiring is already done with: ```text 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. diff --git a/faceai/apps/backend/src/config.js b/faceai/apps/backend/src/config.js index d16182bd..aa71bf61 100644 --- a/faceai/apps/backend/src/config.js +++ b/faceai/apps/backend/src/config.js @@ -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' diff --git a/faceai/apps/frontend/src/components/LegacyHeader.vue b/faceai/apps/frontend/src/components/LegacyHeader.vue index b003f409..1ea350be 100644 --- a/faceai/apps/frontend/src/components/LegacyHeader.vue +++ b/faceai/apps/frontend/src/components/LegacyHeader.vue @@ -1,10 +1,16 @@