feat: custom terminal host
This commit is contained in:
@@ -46,6 +46,9 @@ services:
|
|||||||
- PUSHER_APP_ID
|
- PUSHER_APP_ID
|
||||||
- PUSHER_APP_KEY
|
- PUSHER_APP_KEY
|
||||||
- PUSHER_APP_SECRET
|
- PUSHER_APP_SECRET
|
||||||
|
- TERMINAL_PROTOCOL
|
||||||
|
- TERMINAL_HOST
|
||||||
|
- TERMINAL_PORT
|
||||||
- AUTOUPDATE
|
- AUTOUPDATE
|
||||||
- SELF_HOSTED
|
- SELF_HOSTED
|
||||||
- SSH_MUX_ENABLED
|
- SSH_MUX_ENABLED
|
||||||
|
|||||||
@@ -50,18 +50,34 @@
|
|||||||
|
|
||||||
function initializeWebSocket() {
|
function initializeWebSocket() {
|
||||||
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
||||||
// Only use port if Coolify is used with ip (so it has a port in the url)
|
const predefined = {
|
||||||
let postPath = ':6002/terminal/ws';
|
protocol: "{{ env('TERMINAL_PROTOCOL') }}",
|
||||||
const port = window.location.port;
|
host: "{{ env('TERMINAL_HOST') }}",
|
||||||
if (!port) {
|
port: "{{ env('TERMINAL_PORT') }}"
|
||||||
postPath = '/terminal/ws';
|
|
||||||
}
|
}
|
||||||
let url = window.location.hostname;
|
const connectionString = {
|
||||||
// make sure the port is not included
|
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
|
||||||
url = url.split(':')[0];
|
host: window.location.hostname,
|
||||||
socket = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') +
|
port: ":6002",
|
||||||
url +
|
path: '/terminal/ws'
|
||||||
postPath);
|
}
|
||||||
|
if (predefined.host) {
|
||||||
|
connectionString.host = predefined.host
|
||||||
|
}
|
||||||
|
if (predefined.port) {
|
||||||
|
connectionString.port = `:${predefined.port}`
|
||||||
|
}
|
||||||
|
if (predefined.protocol) {
|
||||||
|
connectionString.protocol = predefined.protocol
|
||||||
|
}
|
||||||
|
if (!window.location.port) {
|
||||||
|
connectionString.port = ''
|
||||||
|
}
|
||||||
|
console.log(connectionString)
|
||||||
|
const url =
|
||||||
|
`${connectionString.protocol}://${connectionString.host}${connectionString.port}${connectionString.path}`
|
||||||
|
console.log(url)
|
||||||
|
socket = new WebSocket(url);
|
||||||
|
|
||||||
socket.onmessage = handleSocketMessage;
|
socket.onmessage = handleSocketMessage;
|
||||||
socket.onerror = (e) => {
|
socket.onerror = (e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user