Skip to content

Commit

Permalink
Update WebSocket URL in terminal.blade.php to include /ws for consi…
Browse files Browse the repository at this point in the history
…stency with the server configuration.
  • Loading branch information
andrasbacsai committed Sep 13, 2024
1 parent cddf847 commit dcf91cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function setupDynamicProxyConfiguration()
0 => 'http',
],
'service' => 'coolify-terminal',
'rule' => "Host(`{$host}`) && PathPrefix(`/terminal`)",
'rule' => "Host(`{$host}`) && PathPrefix(`/terminal/ws`)",
],
],
'services' => [
Expand Down Expand Up @@ -375,7 +375,7 @@ public function setupDynamicProxyConfiguration()
0 => 'https',
],
'service' => 'coolify-terminal',
'rule' => "Host(`{$host}`) && PathPrefix(`/terminal`)",
'rule' => "Host(`{$host}`) && PathPrefix(`/terminal/ws`)",
'tls' => [
'certresolver' => 'letsencrypt',
],
Expand Down Expand Up @@ -413,7 +413,7 @@ public function setupDynamicProxyConfiguration()
handle /app/* {
reverse_proxy coolify-realtime:6001
}
handle /terminal/* {
handle /terminal/ws/* {
reverse_proxy coolify-realtime:6002
}
reverse_proxy coolify:80
Expand Down
6 changes: 3 additions & 3 deletions docker/coolify-realtime/terminal-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const server = http.createServer((req, res) => {

const verifyClient = async (info, callback) => {
const cookies = cookie.parse(info.req.headers.cookie || '');
const origin = new URL(info.origin);
const protocol = origin.protocol;
// const origin = new URL(info.origin);
// const protocol = origin.protocol;
const xsrfToken = cookies['XSRF-TOKEN'];

// Generate session cookie name based on APP_NAME
Expand Down Expand Up @@ -53,7 +53,7 @@ const verifyClient = async (info, callback) => {
};


const wss = new WebSocketServer({ server, path: '/terminal', verifyClient: verifyClient });
const wss = new WebSocketServer({ server, path: '/terminal/ws', verifyClient: verifyClient });
const userSessions = new Map();

wss.on('connection', (ws) => {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (!window.term) {
cols: 80,
rows: 30,
fontFamily: '"Fira Code", courier-new, courier, monospace, "Powerline Extra Symbols"',
cursorBlink: true
cursorBlink: true,
});
window.fitAddon = new FitAddon();
window.term.loadAddon(window.fitAddon);
Expand Down
16 changes: 8 additions & 8 deletions resources/views/livewire/project/shared/terminal.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div x-data="data()">
<div x-show="!terminalActive" class="flex items-center justify-center w-full py-4 mx-auto h-[510px]">
<div class="w-full h-full border rounded dark:bg-coolgray-100 dark:border-coolgray-300 p-1">
{{-- <div x-show="!terminalActive" class="flex items-center justify-center w-full py-4 mx-auto h-[510px]">
<div class="p-1 w-full h-full rounded border dark:bg-coolgray-100 dark:border-coolgray-300">
<span class="font-mono text-sm text-gray-500" x-text="message"></span>
</div>
</div>
</div> --}}
<div x-ref="terminalWrapper"
:class="fullscreen ? 'fullscreen' : 'relative w-full h-full py-4 mx-auto max-h-[510px]'">
<div id="terminal" wire:ignore></div>
<button title="Minimize" x-show="fullscreen" class="fixed top-4 right-4 text-white"
x-on:click="makeFullscreen"><svg class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<button title="Minimize" x-show="fullscreen" class="fixed top-4 right-4 text-white" x-on:click="makeFullscreen"><svg
class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M6 14h4m0 0v4m0-4l-6 6m14-10h-4m0 0V6m0 4l6-6" />
</svg></button>
<button title="Fullscreen" x-show="!fullscreen && terminalActive" class="absolute top-6 right-4 text-white"
<button title="Fullscreen" x-show="!fullscreen && terminalActive" class="absolute right-4 top-6 text-white"
x-on:click="makeFullscreen"><svg class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g fill="none">
<path
Expand All @@ -35,10 +35,10 @@
function initializeWebSocket() {
if (!socket || socket.readyState === WebSocket.CLOSED) {
// Only use port if Coolify is used with ip (so it has a port in the url)
let postPath = ':6002/terminal';
let postPath = ':6002/terminal/ws';
const port = window.location.port;
if (!port) {
postPath = '/terminal';
postPath = '/terminal/ws';
}
let url = window.location.hostname;
// make sure the port is not included
Expand Down

0 comments on commit dcf91cc

Please sign in to comment.