diff --git a/config/reverb.php b/config/reverb.php index d0cc9e7..20687ef 100644 --- a/config/reverb.php +++ b/config/reverb.php @@ -27,11 +27,12 @@ return [ */ 'servers' => [ - 'reverb' => [ 'host' => env('REVERB_SERVER_HOST', '127.0.0.1'), 'port' => env('REVERB_SERVER_PORT', 8080), 'path' => env('REVERB_SERVER_PATH', '/ws'), + 'scheme' => env('REVERB_SERVER_SCHEME', 'https'), + 'key' => env('REVERB_APP_KEY'), 'hostname' => env('REVERB_HOST'), 'options' => [ 'tls' => [], diff --git a/resources/js/webserver/connector.js b/resources/js/webserver/connector.js new file mode 100644 index 0000000..c1efd15 --- /dev/null +++ b/resources/js/webserver/connector.js @@ -0,0 +1,46 @@ +// 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-* + return { + host: host || null, + port: port ? Number(port) : null, + scheme: scheme || null, + path: path || null, + key: key || null, + }; +} + +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', + }; +} + +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 10aabd3..c70aa80 100644 --- a/resources/js/webserver/websocket.js +++ b/resources/js/webserver/websocket.js @@ -1,19 +1,23 @@ import Echo from 'laravel-echo' import Pusher from 'pusher-js' +import {wsConfig} from "./connector.js"; + window.Pusher = Pusher -const host = import.meta.env.VITE_REVERB_HOST || window.location.hostname -const port = Number(import.meta.env.VITE_REVERB_PORT) || 443 -const scheme = (import.meta.env.VITE_REVERB_SCHEME || 'https').toLowerCase() +const host = wsConfig.host || window.location.hostname +const port = Number(wsConfig.port) || 443 // <- post -> port +const scheme = (wsConfig.scheme || 'https').toLowerCase() +const path = wsConfig.path || '/ws' const tls = scheme === 'https' +const key = wsConfig.key window.Echo = new Echo({ broadcaster: 'reverb', - key: import.meta.env.VITE_REVERB_APP_KEY, + key, wsHost: host, wsPort: port, wssPort: port, forceTLS: tls, - enabledTransports: ['ws','wss'], - wsPath: import.meta.env.VITE_REVERB_PATH || '/ws', + enabledTransports: ['ws', 'wss'], + wsPath: path, }) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 038efd9..1a6f8da 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -41,6 +41,12 @@ + @yield('title', config('app.name')) @vite(['resources/css/app.css','resources/js/app.js']) @livewireStyles @@ -65,18 +71,8 @@ {{-- Seite: immer auf volle Höhe und zentriert --}}
- - {{-- --}} -{{-- @dd(request('task'))--}} -{{-- @if (request('task'))--}} -{{-- --}} -{{-- @endif--}} +{{-- --}}
-{{-- --}} -{{-- @include('livewire.system.task-toast')--}} -{{--@if (request('task'))--}} -{{-- --}} -{{-- @endif--}} @yield('content')