diff --git a/src/components/terminal/terminal.js b/src/components/terminal/terminal.js index 6474e5e57..ac67149d7 100644 --- a/src/components/terminal/terminal.js +++ b/src/components/terminal/terminal.js @@ -31,6 +31,7 @@ export default class TerminalComponent { scrollOnUserInput: true, rows: options.rows || 24, cols: options.cols || 80, + port: options.port || 8767, fontSize: terminalSettings.fontSize, fontFamily: terminalSettings.fontFamily, fontWeight: terminalSettings.fontWeight, @@ -566,13 +567,16 @@ export default class TerminalComponent { rows: this.terminal.rows, }; - const response = await fetch("http://localhost:8767/terminals", { - method: "POST", - headers: { - "Content-Type": "application/json", + const response = await fetch( + `http://localhost:${this.options.port}/terminals`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(requestBody), }, - body: JSON.stringify(requestBody), - }); + ); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); @@ -604,7 +608,7 @@ export default class TerminalComponent { this.pid = pid; - const wsUrl = `ws://localhost:8767/terminals/${pid}`; + const wsUrl = `ws://localhost:${this.options.port}/terminals/${pid}`; this.websocket = new WebSocket(wsUrl); @@ -658,13 +662,16 @@ export default class TerminalComponent { if (!this.pid || !this.serverMode) return; try { - await fetch(`http://localhost:8767/terminals/${this.pid}/resize`, { - method: "POST", - headers: { - "Content-Type": "application/json", + await fetch( + `http://localhost:${this.options.port}/terminals/${this.pid}/resize`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ cols, rows }), }, - body: JSON.stringify({ cols, rows }), - }); + ); } catch (error) { console.error("Failed to resize terminal:", error); } @@ -953,9 +960,12 @@ export default class TerminalComponent { if (this.pid && this.serverMode) { try { - await fetch(`http://localhost:8767/terminals/${this.pid}/terminate`, { - method: "POST", - }); + await fetch( + `http://localhost:${this.options.port}/terminals/${this.pid}/terminate`, + { + method: "POST", + }, + ); } catch (error) { console.error("Failed to terminate terminal:", error); }