mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Enhance OIDC callback to reconstruct base URL from proxy headers if present
This commit is contained in:
parent
53a0f5b7bd
commit
24318a4f32
1 changed files with 19 additions and 1 deletions
|
|
@ -71,7 +71,25 @@ export async function GET(request: NextRequest) {
|
|||
token = createSecureToken({ userId: user.id, role: user.role }, secret());
|
||||
}
|
||||
|
||||
const baseUrl = new URL(request.url).origin;
|
||||
// Reconstruit l'origine depuis les en-têtes proxy si présents
|
||||
const headers = request.headers;
|
||||
const forwardedProto = headers.get('x-forwarded-proto');
|
||||
const forwardedHost = headers.get('x-forwarded-host') || headers.get('host');
|
||||
const forwardedPort = headers.get('x-forwarded-port');
|
||||
|
||||
let baseOrigin = '';
|
||||
if (forwardedProto && forwardedHost) {
|
||||
// Ajoute le port si fourni et non déjà inclus dans le host
|
||||
const hasPortInHost = forwardedHost.includes(':');
|
||||
const hostWithPort = !hasPortInHost && forwardedPort
|
||||
? `${forwardedHost}:${forwardedPort}`
|
||||
: forwardedHost;
|
||||
baseOrigin = `${forwardedProto}://${hostWithPort}`;
|
||||
} else {
|
||||
baseOrigin = new URL(request.url).origin;
|
||||
}
|
||||
|
||||
const baseUrl = baseOrigin;
|
||||
const ssoUrl = `${baseUrl}/sso?url=${encodeURIComponent(returnCookie)}&token=${encodeURIComponent(
|
||||
token,
|
||||
)}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue