fix: JWT密钥YAML格式和401错误处理
- 修复JWT密钥在YAML配置文件中未加引号导致解析错误的问题 - 添加dashboard页面401错误处理,自动清除token并跳转登录页
This commit is contained in:
@@ -145,6 +145,7 @@ async function fetchDashboard() {
|
||||
const token = localStorage.getItem('token')
|
||||
if (!token) {
|
||||
console.error('No token found')
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -154,6 +155,13 @@ async function fetchDashboard() {
|
||||
},
|
||||
})
|
||||
|
||||
if (response.status === 401) {
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('user')
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user