Fix 502 errors on container restart and expand API authentication

- Handle 502 Gateway Timeout errors by clearing invalid sessions
- Add graceful session validation failure handling in fetch-thread API
- Expand x-tag authentication to accept additional valid token
- Add debug logging to berth-related API endpoints
- Document the 502 error fix in email system documentation
This commit is contained in:
2025-06-09 23:29:24 +02:00
parent 1866dfd010
commit 48cee6f849
8 changed files with 89 additions and 28 deletions

View File

@@ -45,7 +45,22 @@ export default defineEventHandler(async (event) => {
}
// Decrypt credentials
const { email: userEmail, password } = decryptCredentials(encryptedCredentials);
let userEmail: string;
let password: string;
try {
const decrypted = decryptCredentials(encryptedCredentials);
userEmail = decrypted.email;
password = decrypted.password;
} catch (decryptError) {
console.error('Failed to decrypt credentials - session may be invalid after restart:', decryptError);
// Return empty results for invalid session
return {
success: true,
emails: [],
threads: []
};
}
// First, get emails from MinIO cache if available
const cachedEmails: EmailMessage[] = [];