mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-17 01:49:15 +08:00
fix(dashboard): remove Authorization header and withCredentials from SSE connections
SSE connections to /api/live-log are same-origin (VITE_API_BASE is empty in production, resolves to relative /api path). The Authorization header and withCredentials:true triggered CORS preflight (OPTIONS) requests, but the SSE route only handles GET, causing the preflight to fail.
This commit is contained in:
@@ -123,16 +123,10 @@ export default {
|
||||
|
||||
console.log(`正在连接日志流... (尝试次数: ${this.retryAttempts})`);
|
||||
|
||||
const token = localStorage.getItem("token");
|
||||
|
||||
this.eventSource = new EventSourcePolyfill(
|
||||
resolveApiUrl("/api/live-log"),
|
||||
{
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : "",
|
||||
},
|
||||
heartbeatTimeout: 300000,
|
||||
withCredentials: true,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -180,16 +180,10 @@ export default {
|
||||
this.eventSource = null;
|
||||
}
|
||||
|
||||
const token = localStorage.getItem("token");
|
||||
|
||||
this.eventSource = new EventSourcePolyfill(
|
||||
resolveApiUrl("/api/live-log"),
|
||||
{
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : "",
|
||||
},
|
||||
heartbeatTimeout: 300000,
|
||||
withCredentials: true,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user