fixes lol
This commit is contained in:
parent
a206a606f7
commit
07b8e12197
10 changed files with 211 additions and 57 deletions
|
|
@ -200,10 +200,26 @@
|
|||
return;
|
||||
}
|
||||
|
||||
// Get token from localStorage if available (for authenticated users)
|
||||
const token = typeof localStorage !== 'undefined' ? localStorage.getItem('token') : null;
|
||||
console.log('Chat connecting with realmId:', realmId, token ? '(authenticated)' : '(guest)');
|
||||
chatWebSocket.connect(realmId, token);
|
||||
// Connect to chat - fetch fresh token if authenticated (uses httpOnly cookies)
|
||||
(async () => {
|
||||
let token = null;
|
||||
try {
|
||||
const response = await fetch('/api/auth/refresh', {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.token) {
|
||||
token = data.token;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Not authenticated or refresh failed - connect as guest
|
||||
}
|
||||
console.log('Chat connecting with realmId:', realmId, token ? '(authenticated)' : '(guest)');
|
||||
chatWebSocket.connect(realmId, token);
|
||||
})();
|
||||
|
||||
// Function to scroll to newest messages (bottom for UP flow, top for DOWN flow)
|
||||
const scrollToBottom = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue