Fix login redirect to use absolute URL

- Use window.location.origin for redirect to ensure it works from any path
- Redirects to chat (#chat) after successful authentication
- Maintains support for custom redirect parameter
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-02-04 13:20:14 -03:00
parent 375b457f48
commit 5e10222a94

View file

@ -1266,16 +1266,16 @@
if (response.redirect || response.success) {
// Check for redirect parameter in URL
const urlParams = new URLSearchParams(window.location.search);
const redirectUrl = urlParams.get('redirect') || response.redirect || "/#chat";
window.location.href = redirectUrl;
const redirectUrl = urlParams.get('redirect') || response.redirect;
window.location.href = redirectUrl ? redirectUrl : window.location.origin + "/#chat";
}
} catch (e) {
// If response is not JSON, check for redirect header
if (event.detail.xhr.status === 200) {
// Check for redirect parameter in URL
const urlParams = new URLSearchParams(window.location.search);
const redirectUrl = urlParams.get('redirect') || "/#chat";
window.location.href = redirectUrl;
const redirectUrl = urlParams.get('redirect');
window.location.href = redirectUrl ? redirectUrl : window.location.origin + "/#chat";
}
}
} else {