Skip to content

Commit

Permalink
fix: support wss for the https request
Browse files Browse the repository at this point in the history
Signed-off-by: saltbo <[email protected]>
  • Loading branch information
saltbo committed Dec 6, 2022
1 parent 2e335b3 commit 79d26a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/xterm/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import dayjs from "dayjs";

const wsOrigin = `ws://${location.host}/proxies`;
let scheme = "ws";
if (location.protocol === "https:") {
scheme = "wss";
}
const wsOrigin = `${scheme}://${location.host}/proxies`;

export const lokiTail = (query: Object, start: string) => {
const queryStr = Object.entries(query)
Expand Down
6 changes: 5 additions & 1 deletion src/libs/helper/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export const buildApolloClient = () => {
});

// 创建一个 WebSocket 连接:
let scheme = "ws";
if (location.protocol === "https:") {
scheme = "wss";
}
const wsLink = new WebSocketLink({
uri: `ws://${location.host}/api/graphql`,
uri: `${scheme}://${location.host}/api/graphql`,
options: {
// reconnect: true,
},
Expand Down

0 comments on commit 79d26a0

Please sign in to comment.