Skip to content

Commit

Permalink
fix(terminal): use wss protocol to connect terminal when https is ava…
Browse files Browse the repository at this point in the history
…ilable (#625)
  • Loading branch information
powerfooI authored Nov 12, 2024
1 parent 3b4bfeb commit d280b4d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ui/src/components/Terminal/terminal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { intl } from '@/utils/intl';
import { Terminal } from '@xterm/xterm';
import { Button, Modal } from 'antd';

import React from 'react';
import { Terminal } from '@xterm/xterm';
import { intl } from '@/utils/intl';

export interface ITerminal {
terminalId: string;
Expand Down Expand Up @@ -34,8 +35,11 @@ export const OBTerminal: React.FC<ITerminal> = (props) => {
const cols = Math.floor(containerWidth / 9.2);
const rows = Math.floor(cols / 4);
term.resize(cols, rows);

const protocol = location.protocol === 'https:' ? 'wss' : 'ws';

const ws = new WebSocket(
`ws://${location.host}/api/v1/terminal/${terminalId}?cols=${cols}&rows=${rows}`,
`${protocol}://${location.host}/api/v1/terminal/${terminalId}?cols=${cols}&rows=${rows}`,
);
term.write('Hello from \x1B[1;3;31mOceanBase\x1B[0m\r\n');

Expand Down

0 comments on commit d280b4d

Please sign in to comment.