fix: handle HTTP redirects in event stream and improve JWT expiration handling
This commit is contained in:
@@ -263,6 +263,13 @@ function App() {
|
||||
[token],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (token && isJwtExpired(token)) {
|
||||
clearLocalToken()
|
||||
setToken(null)
|
||||
}
|
||||
}, [token])
|
||||
|
||||
async function login() {
|
||||
clearLocalToken()
|
||||
try {
|
||||
@@ -298,6 +305,12 @@ function App() {
|
||||
|
||||
async function submitMessage() {
|
||||
if (!input.trim() || !token) return
|
||||
if (isJwtExpired(token)) {
|
||||
clearLocalToken()
|
||||
setToken(null)
|
||||
setError('Session expired, please log in again.')
|
||||
return
|
||||
}
|
||||
|
||||
const userMessage: Message = { role: 'user', content: input.trim() }
|
||||
const messageBatch = [...messages, userMessage]
|
||||
|
||||
Reference in New Issue
Block a user