fix: host connections failing with "Authentication failed" (#791)

Co-authored-by: LukeGus <bugattiguy527@gmail.com>
This commit is contained in:
ZacharyZcR
2026-05-18 05:17:10 +08:00
committed by GitHub
parent a354a45b1c
commit 65d67e6f79
3 changed files with 16 additions and 0 deletions
+6
View File
@@ -257,6 +257,12 @@ wss.on("connection", async (ws: WebSocket, req) => {
}
}
if (!token) {
const urlObj = new URL(req.url || "", "http://localhost");
const qp = urlObj.searchParams.get("token");
if (qp) token = qp;
}
if (!token) {
ws.close(1008, "Authentication required");
return;
+6
View File
@@ -505,6 +505,12 @@ wss.on("connection", async (ws: WebSocket, req) => {
}
}
if (!token) {
const urlObj = new URL(req.url || "", "http://localhost");
const qp = urlObj.searchParams.get("token");
if (qp) token = qp;
}
if (!token) {
ws.close(1008, "Authentication required");
return;
+4
View File
@@ -884,6 +884,10 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
.replace(/^https?:\/\//, "")
.replace(/\/$/, "");
baseWsUrl = `${wsProtocol}${wsHost}/ssh/websocket/`;
const storedJwt = localStorage.getItem("jwt");
if (storedJwt) {
baseWsUrl += `?token=${encodeURIComponent(storedJwt)}`;
}
}
} else {
baseWsUrl = `${getBasePath()}/ssh/websocket/`;