From 75ffc68c7845f237377ca8e3d63baadc290c86eb Mon Sep 17 00:00:00 2001 From: boban Date: Mon, 29 Sep 2025 02:32:33 +0200 Subject: [PATCH] Anpassenden der Websocket Konfiguration --- an config:clear | 30 ++++++++++++++ config/broadcasting.php | 2 +- resources/js/bootstrap.js | 2 +- resources/js/webserver/connector.js | 56 +++++++-------------------- resources/js/webserver/websocket.js | 8 ++-- resources/views/layouts/app.blade.php | 8 ++-- 6 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 an config:clear diff --git a/an config:clear b/an config:clear new file mode 100644 index 0000000..35b2cbd --- /dev/null +++ b/an config:clear @@ -0,0 +1,30 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R \ No newline at end of file diff --git a/config/broadcasting.php b/config/broadcasting.php index 49da43a..907c6fe 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -52,7 +52,7 @@ return [ 'secret' => env('REVERB_APP_SECRET'), 'app_id' => env('REVERB_APP_ID'), 'options' => [ - 'host' => env('REVERB_HOST'), // öffentlich (gleicht VITE_REVERB_HOST) + 'host' => env('REVERB_HOST'), 'port' => (int) env('REVERB_PORT', 443), 'scheme' => env('REVERB_SCHEME', 'https'), 'path' => env('REVERB_PATH', '/ws'), diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index a96db8f..e67d5c1 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -3,4 +3,4 @@ window.axios = axios; window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; -import './webserver/websocket.js' +import './webserver/websocket.js'; diff --git a/resources/js/webserver/connector.js b/resources/js/webserver/connector.js index c1efd15..16085c3 100644 --- a/resources/js/webserver/connector.js +++ b/resources/js/webserver/connector.js @@ -1,46 +1,18 @@ -// resources/js/plugins/connector.js -function readMetaConfig() { - const el = (typeof document !== 'undefined') - ? document.querySelector('meta[name="reverb"]') - : null; - if (!el) return null; - - const { host, port, scheme, path, key } = el.dataset; // data-* +function fromWindow() { + const isHttps = typeof window !== 'undefined' && window.location.protocol === 'https:' return { - host: host || null, - port: port ? Number(port) : null, - scheme: scheme || null, - path: path || null, - key: key || null, - }; + host: (typeof window !== 'undefined' && window.location.hostname) || '127.0.0.1', + port: isHttps ? 443 : 80, + scheme: isHttps ? 'https' : 'http', + path: '/ws', + key: import.meta?.env?.VITE_REVERB_APP_KEY || '' + } } +const meta = readMetaConfig() +const fallback = readViteEnv() +const base = meta ?? fallback ?? fromWindow() -function readViteEnv() { - const env = (typeof import.meta !== 'undefined' && import.meta.env) ? import.meta.env : {}; - return { - host: env.VITE_REVERB_HOST || env.APP_HOST || '127.0.0.1', - port: env.VITE_REVERB_PORT ? Number(env.VITE_REVERB_PORT) : 443, - scheme: (env.VITE_REVERB_SCHEME || 'https').toLowerCase(), - path: env.VITE_REVERB_PATH || '/ws', - key: env.VITE_REVERB_APP_KEY || 'mailwolt-yhp47tbt1aebhr1fgvgj', - }; +// harte Korrektur: NIEMALS 8080 nach außen geben +if (Number(base.port) === 8080 && (base.scheme || 'https').startsWith('http')) { + base.port = (base.scheme === 'https') ? 443 : 80 } - -function normalize(cfg) { - const c = { ...cfg }; - if (!c.path || typeof c.path !== 'string') c.path = '/ws'; - if (!c.path.startsWith('/')) c.path = '/' + c.path; - c.wsScheme = (c.scheme === 'http' ? 'ws' : 'wss'); - return c; -} - -const fromMeta = readMetaConfig(); -const base = fromMeta ?? readViteEnv(); - -export const wsConfig = normalize({ - host: base.host || '127.0.0.1', - port: base.port || 443, - scheme: base.scheme || 'https', - path: base.path || '/ws', - key: base.key || 'mailwolt-yhp47tbt1aebhr1fgvgj', -}); diff --git a/resources/js/webserver/websocket.js b/resources/js/webserver/websocket.js index c70aa80..37708ca 100644 --- a/resources/js/webserver/websocket.js +++ b/resources/js/webserver/websocket.js @@ -1,14 +1,14 @@ import Echo from 'laravel-echo' import Pusher from 'pusher-js' -import {wsConfig} from "./connector.js"; +import { wsConfig } from './connector.js' window.Pusher = Pusher const host = wsConfig.host || window.location.hostname -const port = Number(wsConfig.port) || 443 // <- post -> port +const port = Number(wsConfig.port) || 443 // <— port! const scheme = (wsConfig.scheme || 'https').toLowerCase() const path = wsConfig.path || '/ws' -const tls = scheme === 'https' +const tls = scheme === 'https' // <— boolean const key = wsConfig.key window.Echo = new Echo({ @@ -18,6 +18,6 @@ window.Echo = new Echo({ wsPort: port, wssPort: port, forceTLS: tls, - enabledTransports: ['ws', 'wss'], + enabledTransports: ['ws','wss'], wsPath: path, }) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 89e5e4c..924ddbb 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -4,11 +4,11 @@ + data-key="{{ env('REVERB_APP_KEY') }}"> @yield('title', config('app.name')) @vite(['resources/css/app.css','resources/js/app.js']) @livewireStyles