fix: resolve login network error behind Traefik proxy

This commit is contained in:
Ashim Kumar
2026-02-20 15:20:03 +06:00
parent 8e02b9ad09
commit 4789771836
3 changed files with 23 additions and 10 deletions

View File

@@ -260,7 +260,7 @@
<div class="login-footer">
<i class="bi bi-shield-lock me-1"></i>
Audiobook Maker Pro v3.1
Audiobook Maker Pro v4
</div>
</div>
</div>
@@ -295,18 +295,33 @@
// Hide previous error
errorDiv.classList.remove('visible');
// Client-side validation
if (!username || !password) {
errorText.textContent = 'Please enter username and password.';
errorDiv.classList.add('visible');
return;
}
// Show loading
loginBtn.disabled = true;
btnText.textContent = 'Signing in...';
spinner.style.display = 'inline-block';
try {
const response = await fetch('/api/auth/login', {
const response = await fetch(window.location.origin + '/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
body: JSON.stringify({ username, password }),
redirect: 'follow',
credentials: 'same-origin'
});
// Handle non-JSON responses (e.g., 500 server error pages)
const contentType = response.headers.get('content-type') || '';
if (!contentType.includes('application/json')) {
throw new Error('Server returned status ' + response.status);
}
const data = await response.json();
if (data.error) {
@@ -326,7 +341,8 @@
window.location.href = '/';
} catch (error) {
errorText.textContent = 'Network error. Please try again.';
console.error('Login fetch error:', error);
errorText.textContent = 'Connection error. Please try again.';
errorDiv.classList.add('visible');
loginBtn.disabled = false;
btnText.textContent = 'Sign In';