Till Tomczak 3d576f0642 Verbessere OAuth-Unterstützung für m040tbaraspi001.de040.corpintra.net
- Füge dynamische Erkennung und Konfiguration von Hostnamen hinzu
- Erweitere Caddy-Konfiguration für m040tbaraspi001.de040.corpintra.net
- Konfiguriere OAuth mit expliziter NEXT_PUBLIC_OAUTH_CALLBACK_URL
- Passe Deployment-Skripte für Unternehmens-Hostname an
- Füge verbesserte Logging und Validierung für OAuth-Callbacks hinzu
- Füge ALLOWED_CALLBACK_HOSTS für Hostname-Validierung hinzu

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-01 14:10:48 +02:00

51 lines
1.6 KiB
TypeScript

// Basis-URL für Backend-API
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://192.168.0.105:5000";
// Frontend-URL für Callbacks - unterstützt mehrere Domains
const getFrontendUrl = () => {
// Priorität 1: Explizit gesetzte Umgebungsvariable
if (process.env.NEXT_PUBLIC_FRONTEND_URL) {
return process.env.NEXT_PUBLIC_FRONTEND_URL;
}
// Priorität 2: Spezifischer Hostname für das Netzwerk
if (typeof window !== 'undefined') {
// Im Browser: Prüfen auf m040tbaraspi001.de040.corpintra.net
const hostname = window.location.hostname;
if (hostname === 'm040tbaraspi001' ||
hostname === 'm040tbaraspi001.de040.corpintra.net' ||
hostname.includes('corpintra.net')) {
return `http://${hostname}`;
}
}
// Priorität 3: Default für Localhost
return "http://localhost:3000";
};
export const FRONTEND_URL = getFrontendUrl();
// OAuth Callback URL - muss exakt mit der registrierten URL in GitHub übereinstimmen
export const OAUTH_CALLBACK_URL = process.env.NEXT_PUBLIC_OAUTH_CALLBACK_URL ||
`${FRONTEND_URL}/auth/login/callback`;
// Liste der erlaubten Hostnamen für OAuth-Callbacks
export const ALLOWED_CALLBACK_HOSTS = [
'localhost',
'm040tbaraspi001',
'm040tbaraspi001.de040.corpintra.net',
'192.168.0.105'
];
// Endpunkte für die verschiedenen Ressourcen
export const API_ENDPOINTS = {
PRINTERS: `${API_BASE_URL}/api/printers`,
JOBS: `${API_BASE_URL}/api/jobs`,
USERS: `${API_BASE_URL}/api/users`,
// OAuth-spezifische Endpunkte
AUTH: {
LOGIN: `${API_BASE_URL}/api/auth/login`,
CALLBACK: `${API_BASE_URL}/api/auth/callback`,
}
};