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:
LIghtJUNction
2026-03-28 12:27:52 +08:00
parent 1faeee3732
commit 7a6cea3da1
2 changed files with 0 additions and 12 deletions

View File

@@ -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,
},
);

View File

@@ -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,
},
);