Pushing stage runs CI and deploys to stage.transcribe.z00.nu with its own data, Reverb credentials, and Caddy network.
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import Echo from 'laravel-echo';
|
|
|
|
import Pusher from 'pusher-js';
|
|
window.Pusher = Pusher;
|
|
|
|
function metaContent(name) {
|
|
return document.querySelector(`meta[name="${name}"]`)?.getAttribute('content')?.trim() || '';
|
|
}
|
|
|
|
const isLocalHost = ['localhost', '127.0.0.1'].includes(window.location.hostname);
|
|
const internalHosts = new Set(['', 'reverb', 'localhost', '127.0.0.1']);
|
|
|
|
const key = metaContent('reverb-key') || import.meta.env.VITE_REVERB_APP_KEY;
|
|
|
|
let host = metaContent('reverb-host') || import.meta.env.VITE_REVERB_HOST || '';
|
|
let port = metaContent('reverb-port') || import.meta.env.VITE_REVERB_PORT || '';
|
|
let scheme = metaContent('reverb-scheme') || import.meta.env.VITE_REVERB_SCHEME || 'https';
|
|
|
|
if (!isLocalHost && internalHosts.has(host)) {
|
|
host = `reverb.${window.location.hostname}`;
|
|
port = '443';
|
|
scheme = 'https';
|
|
} else if (isLocalHost && host === 'reverb') {
|
|
host = import.meta.env.VITE_REVERB_HOST || 'localhost';
|
|
port = import.meta.env.VITE_REVERB_PORT || '8081';
|
|
scheme = import.meta.env.VITE_REVERB_SCHEME || 'http';
|
|
}
|
|
|
|
window.Echo = new Echo({
|
|
broadcaster: 'reverb',
|
|
key,
|
|
wsHost: host,
|
|
wsPort: port || 80,
|
|
wssPort: port || 443,
|
|
forceTLS: scheme === 'https',
|
|
enabledTransports: ['ws', 'wss'],
|
|
authEndpoint: '/broadcasting/auth',
|
|
auth: {
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content'),
|
|
},
|
|
},
|
|
});
|