From edbfe2848c9623afe3be7fdcb987ce7bdb07198f Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Tue, 19 May 2026 00:07:55 +0200 Subject: [PATCH] fix(front): fix issue with already declared constants on release mode - ensure not loading twice the same variables, namespace to ensure it in the future - end to end tests where successfull, need to check it is not reusing a previous release (in cache from build CI) - fix: #377 #378 --- src/main.rs | 2 ++ static/js/core/fetchWrapper.js | 8 ++++---- static/js/features/auth/auth.js | 1 - tests/e2e/playwright.config.ts | 6 +++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7a68011a..16d17614 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,6 +128,8 @@ async fn main() -> Result<(), Box> { oxicloud::interfaces::middleware::trusted_proxy::log_config(); + tracing::info!("OxiCloud v{}", env!("CARGO_PKG_VERSION")); + // Load configuration from environment variables let config = common::config::AppConfig::from_env(); diff --git a/static/js/core/fetchWrapper.js b/static/js/core/fetchWrapper.js index 13839d33..ded0840a 100644 --- a/static/js/core/fetchWrapper.js +++ b/static/js/core/fetchWrapper.js @@ -30,8 +30,8 @@ import { getCsrfHeaders } from './csrf.js'; -const REFRESH_ENDPOINT = '/api/auth/refresh'; -const USER_DATA_KEY = 'oxicloud_user'; +const WRAPPER_REFRESH_ENDPOINT = '/api/auth/refresh'; +const WRAPPER_USER_DATA_KEY = 'oxicloud_user'; /** Captured before patching — the only safe fetch inside this module. */ let _originalFetch = window.fetch.bind(window); @@ -47,7 +47,7 @@ async function _refresh() { // Must use _originalFetch to avoid re-entering the interceptor. _refreshInFlight = (async () => { try { - const r = await _originalFetch(REFRESH_ENDPOINT, { + const r = await _originalFetch(WRAPPER_REFRESH_ENDPOINT, { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', ...getCsrfHeaders() }, @@ -95,7 +95,7 @@ function installFetchInterceptor() { const refreshed = await _refresh(); if (!refreshed) { - localStorage.removeItem(USER_DATA_KEY); + localStorage.removeItem(WRAPPER_USER_DATA_KEY); window.location.href = '/login?source=session_expired'; throw new Error('Session expired'); } diff --git a/static/js/features/auth/auth.js b/static/js/features/auth/auth.js index 05a2d612..61aa0d7a 100644 --- a/static/js/features/auth/auth.js +++ b/static/js/features/auth/auth.js @@ -1277,4 +1277,3 @@ function redirectToMainApp() { window.location.href = '/login?error=redirect_failed'; } } - diff --git a/tests/e2e/playwright.config.ts b/tests/e2e/playwright.config.ts index 5016a6a7..20195e7a 100644 --- a/tests/e2e/playwright.config.ts +++ b/tests/e2e/playwright.config.ts @@ -17,6 +17,10 @@ function loadEnv(filePath: string): Record { const commonEnv = loadEnv(path.join(__dirname, '../common/server.env')); +console.log(`starting playwright with env BUILD_TARGET=${process.env.BUILD_TARGET ?? "debug"}`); + +const workspace=process.env.GITHUB_WORKSPACE ?? path.join(__dirname, '../..'); + export default defineConfig({ testDir: './scenarios', fullyParallel: true, @@ -49,7 +53,7 @@ export default defineConfig({ webServer: { command: process.env.BUILD_TARGET - ? `${process.env.GITHUB_WORKSPACE}/target/${process.env.BUILD_TARGET}/oxicloud` + ? `${workspace}/target/${process.env.BUILD_TARGET}/oxicloud` : 'cargo run', url: 'http://localhost:8087', timeout: 600_000,