Skip to content

Commit

Permalink
fix: session expired front end message
Browse files Browse the repository at this point in the history
  • Loading branch information
supermandee committed Dec 12, 2024
1 parent e2e6aab commit 92205e4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions static/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ async function sendMessage() {
body: `query=${encodeURIComponent(message)}`
});

// Handle 401 Unauthorized
if (response.status === 401) {
const json = await response.json();
botMessage.innerHTML = `<a href="${json.redirect}">Session expired. Log in again</a>`;
showError(json.error || 'Session expired. Please log in again.');
return; // Stop further processing
}

// Handle other non-OK responses
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
Expand Down

0 comments on commit 92205e4

Please sign in to comment.