Update Websocket Connection without VITE in PROD/DEV
parent
3d3ea31e7a
commit
af735c5012
|
|
@ -27,11 +27,12 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'servers' => [
|
'servers' => [
|
||||||
|
|
||||||
'reverb' => [
|
'reverb' => [
|
||||||
'host' => env('REVERB_SERVER_HOST', '127.0.0.1'),
|
'host' => env('REVERB_SERVER_HOST', '127.0.0.1'),
|
||||||
'port' => env('REVERB_SERVER_PORT', 8080),
|
'port' => env('REVERB_SERVER_PORT', 8080),
|
||||||
'path' => env('REVERB_SERVER_PATH', '/ws'),
|
'path' => env('REVERB_SERVER_PATH', '/ws'),
|
||||||
|
'scheme' => env('REVERB_SERVER_SCHEME', 'https'),
|
||||||
|
'key' => env('REVERB_APP_KEY'),
|
||||||
'hostname' => env('REVERB_HOST'),
|
'hostname' => env('REVERB_HOST'),
|
||||||
'options' => [
|
'options' => [
|
||||||
'tls' => [],
|
'tls' => [],
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
|
});
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
import Echo from 'laravel-echo'
|
import Echo from 'laravel-echo'
|
||||||
import Pusher from 'pusher-js'
|
import Pusher from 'pusher-js'
|
||||||
|
import {wsConfig} from "./connector.js";
|
||||||
|
|
||||||
window.Pusher = Pusher
|
window.Pusher = Pusher
|
||||||
|
|
||||||
const host = import.meta.env.VITE_REVERB_HOST || window.location.hostname
|
const host = wsConfig.host || window.location.hostname
|
||||||
const port = Number(import.meta.env.VITE_REVERB_PORT) || 443
|
const port = Number(wsConfig.port) || 443 // <- post -> port
|
||||||
const scheme = (import.meta.env.VITE_REVERB_SCHEME || 'https').toLowerCase()
|
const scheme = (wsConfig.scheme || 'https').toLowerCase()
|
||||||
|
const path = wsConfig.path || '/ws'
|
||||||
const tls = scheme === 'https'
|
const tls = scheme === 'https'
|
||||||
|
const key = wsConfig.key
|
||||||
|
|
||||||
window.Echo = new Echo({
|
window.Echo = new Echo({
|
||||||
broadcaster: 'reverb',
|
broadcaster: 'reverb',
|
||||||
key: import.meta.env.VITE_REVERB_APP_KEY,
|
key,
|
||||||
wsHost: host,
|
wsHost: host,
|
||||||
wsPort: port,
|
wsPort: port,
|
||||||
wssPort: port,
|
wssPort: port,
|
||||||
forceTLS: tls,
|
forceTLS: tls,
|
||||||
enabledTransports: ['ws','wss'],
|
enabledTransports: ['ws', 'wss'],
|
||||||
wsPath: import.meta.env.VITE_REVERB_PATH || '/ws',
|
wsPath: path,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="reverb"
|
||||||
|
data-host="{{ config('reverb.servers.reverb.host') }}"
|
||||||
|
data-port="{{ config('reverb.servers.reverb.port') }}"
|
||||||
|
data-scheme="{{ config('reverb.servers.reverb.scheme') }}"
|
||||||
|
data-path="{{ config('reverb.servers.reverb.path') }}"
|
||||||
|
data-key="{{ config('reverb.servers.reverb.key') }}">
|
||||||
<title>@yield('title', config('app.name'))</title>
|
<title>@yield('title', config('app.name'))</title>
|
||||||
@vite(['resources/css/app.css','resources/js/app.js'])
|
@vite(['resources/css/app.css','resources/js/app.js'])
|
||||||
@livewireStyles
|
@livewireStyles
|
||||||
|
|
@ -65,18 +71,8 @@
|
||||||
|
|
||||||
{{-- Seite: immer auf volle Höhe und zentriert --}}
|
{{-- Seite: immer auf volle Höhe und zentriert --}}
|
||||||
<main class="min-h-[calc(100dvh-64px)] grid place-items-center px-4">
|
<main class="min-h-[calc(100dvh-64px)] grid place-items-center px-4">
|
||||||
<livewire:system.toast-hub />
|
{{-- <livewire:system.toast-hub/>--}}
|
||||||
{{-- <livewire:system.task-toast :taskKey="'issue-cert:mail.example.com'" />--}}
|
|
||||||
{{-- @dd(request('task'))--}}
|
|
||||||
{{-- @if (request('task'))--}}
|
|
||||||
{{-- <livewire:system.task-toast :taskKey="request('task')" />--}}
|
|
||||||
{{-- @endif--}}
|
|
||||||
<div id="toastra-root" class="absolute pointer-events-none"></div>
|
<div id="toastra-root" class="absolute pointer-events-none"></div>
|
||||||
{{-- <livewire:system.task-toast :taskKey="'issue-cert:mail.example.com'" />--}}
|
|
||||||
{{-- @include('livewire.system.task-toast')--}}
|
|
||||||
{{--@if (request('task'))--}}
|
|
||||||
{{-- <livewire:system.task-toast :taskKey="request('task')" />--}}
|
|
||||||
{{-- @endif--}}
|
|
||||||
@yield('content')
|
@yield('content')
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue