fix: CORS layer — corrige 'serveur injoignable' dans le navigateur

- Ajout CorsLayer::permissive() au router axum
- Répond aux requêtes OPTIONS (preflight CORS)
- Le header X-API-Key rendait les requêtes non-simples → preflight obligatoire
- Sans réponse OPTIONS, le navigateur bloquait → 'Failed to fetch'
- Curl fonctionnait car pas de preflight
This commit is contained in:
2026-06-25 15:33:02 -04:00
parent 4917dad351
commit 62e63e441a
4 changed files with 11 additions and 9 deletions
+3 -3
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Changelog — imagod-web v0.2.0+build.25-41fcb23-dirty</title>
<title>Changelog — imagod-web v0.2.0+build.26-4917dad-dirty</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>">
<style>
* { margin:0; padding:0; box-sizing:border-box; }
@@ -37,7 +37,7 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
</head>
<body>
<header>
<h1>📋 imagod-web <span class="version-badge">v0.2.0+build.25-41fcb23-dirty</span></h1>
<h1>📋 imagod-web <span class="version-badge">v0.2.0+build.26-4917dad-dirty</span></h1>
<nav>
<a href="/">🖼️ Galerie</a>
<a href="/changelog" class="active">📋 Changelog</a>
@@ -107,6 +107,6 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
<h2>Légende des tags</h2>
</main>
<footer>imagod-web v0.2.0+build.25-41fcb23-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
<footer>imagod-web v0.2.0+build.26-4917dad-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
</body>
</html>
+3 -3
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aide & Roadmap — imagod-web v0.2.0+build.25-41fcb23-dirty</title>
<title>Aide & Roadmap — imagod-web v0.2.0+build.26-4917dad-dirty</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>">
<style>
* { margin:0; padding:0; box-sizing:border-box; }
@@ -37,7 +37,7 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
</head>
<body>
<header>
<h1>❓ imagod-web <span class="version-badge">v0.2.0+build.25-41fcb23-dirty</span></h1>
<h1>❓ imagod-web <span class="version-badge">v0.2.0+build.26-4917dad-dirty</span></h1>
<nav>
<a href="/">🖼️ Galerie</a>
<a href="/changelog">📋 Changelog</a>
@@ -169,6 +169,6 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
<p>5. <strong>Corriger le backend Imago</strong> (thumbnails, upload, stockage)</p>
</main>
<footer>imagod-web v0.2.0+build.25-41fcb23-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
<footer>imagod-web v0.2.0+build.26-4917dad-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
</body>
</html>
+1 -1
View File
@@ -465,7 +465,7 @@
<button class="btn" id="clear-btn" style="display:none">✕</button>
</div>
<button class="btn accent" id="header-upload-btn" onclick="document.getElementById('drop-zone').scrollIntoView({behavior:'smooth'}); document.getElementById('file-input').click()">📤 Upload</button>
<span class="version-badge" id="version-badge">v0.2.0+build.25-41fcb23-dirty</span>
<span class="version-badge" id="version-badge">v0.2.0+build.26-4917dad-dirty</span>
</div>
<!-- ─── Navigation ─── -->
+4 -2
View File
@@ -11,6 +11,7 @@ use std::net::SocketAddr;
use std::sync::Arc;
use std::collections::HashSet;
use tokio::sync::Mutex;
use tower_http::cors::CorsLayer;
use crate::imago_client::ImagoClient;
use crate::config::Config;
@@ -54,11 +55,12 @@ pub async fn serve_with_config(host: &str, port: u16, config: &Config) -> anyhow
in_flight: Mutex::new(HashSet::new()),
};
// Router principal
// Router principal — avec CORS permissif pour les requêtes cross-origin et preflight
let app = Router::new()
.merge(routes::api_routes(state))
.route("/ws", axum::routing::get(ws::ws_handler).with_state(ws_hub))
.fallback(serve_static);
.fallback(serve_static)
.layer(CorsLayer::permissive());
let addr: SocketAddr = format!("{}:{}", host, port).parse()?;
tracing::info!("Dashboard web démarré sur http://{}", addr);