// authConfig.js const hostname = window.location.hostname; const protocol = window.location.protocol; // Détection environnements (utile pour le debug) const isProduction = hostname === "mygta.ensup-adm.net"; // --- API URL --- // On utilise TOUJOURS /api car le proxy Vite (port 80) va rediriger vers le backend (port 3000) // Cela évite les problèmes CORS et les problèmes de ports fermés (8000) export const API_BASE_URL = "/api"; // --- MSAL Config --- export const msalConfig = { auth: { clientId: "4bb4cc24-bac3-427c-b02c-5d14fc67b561", authority: "https://login.microsoftonline.com/9840a2a0-6ae1-4688-b03d-d2ec291be0f9", // En prod, on force l'URL sans slash final pour être propre redirectUri: isProduction ? "https://mygta.ensup-adm.net" : `${protocol}//${hostname}`, }, cache: { cacheLocation: "sessionStorage", storeAuthStateInCookie: false, }, }; // --- Permissions Graph --- export const loginRequest = { scopes: [ "User.Read", "User.Read.All", "Group.Read.All", "GroupMember.Read.All", "Mail.Send", ], }; console.log("🔧 Config Auth:", { hostname, protocol, API_BASE_URL, redirectUri: msalConfig.auth.redirectUri, });