mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
ui: handle WebSocket 403 unauthorized errors properly
When WebSocket connection fails due to 403 unauthorized status from server, browser WebSocket API cannot distinguish HTTP status codes and only fires a generic 'error' event. Redirect to /connect/:devid HTTP endpoint so that browser can properly capture and handle the 403 status code response. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
@@ -267,7 +267,12 @@ export default {
|
||||
}
|
||||
})
|
||||
|
||||
socket.addEventListener('error', () => this.closed())
|
||||
socket.addEventListener('error', () => {
|
||||
let href = `/connect/${this.devid}`
|
||||
if (group)
|
||||
href += `?group=${group}`
|
||||
window.location.href = href
|
||||
})
|
||||
|
||||
socket.addEventListener('message', ev => {
|
||||
const data = ev.data
|
||||
|
||||
Reference in New Issue
Block a user