From 8e422cbc5bf3abe620333812b77183c94f602a0a Mon Sep 17 00:00:00 2001 From: Henrik B Hansen Date: Wed, 4 Sep 2019 08:48:06 +0200 Subject: [PATCH] Make it possible to customise the port the dashboard connects to (#124) * Make it possible to customise the port the dashboard connects to. * Fixed so both wsPort and wssPort are changed. * Changed env port name and added path * Fixed typo in wsPath * Moved port into dashboard section in config * Changed env name to LARAVEL_WEBSOCKETS_PORT --- config/websockets.php | 8 ++++++++ resources/views/dashboard.blade.php | 7 ++++--- src/Dashboard/Http/Controllers/ShowDashboard.php | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/websockets.php b/config/websockets.php index cf46545..6a2e7f0 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -4,6 +4,13 @@ use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize; return [ + /* + * Set a custom dashboard configuration + */ + 'dashboard' => [ + 'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001), + ], + /* * This package comes with multi tenancy out of the box. Here you can * configure the different apps that can use the webSockets server. @@ -20,6 +27,7 @@ return [ 'name' => env('APP_NAME'), 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), + 'path' => env('PUSHER_APP_PATH'), 'capacity' => null, 'enable_client_messages' => false, 'enable_statistics' => true, diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 0d97e7e..d20672b 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -95,8 +95,8 @@ connected: false, chart: null, pusher: null, - port: 6001, app: null, + port: {{ $port }}, apps: {!! json_encode($apps) !!}, form: { channel: null, @@ -114,8 +114,9 @@ connect() { this.pusher = new Pusher(this.app.key, { wsHost: this.app.host === null ? window.location.hostname : this.app.host, - wsPort: this.port, - wssPort: this.port, + wsPort: this.port === null ? 6001 : this.port, + wssPort: this.port === null ? 6001 : this.port, + wsPath: this.app.path === null ? '' : this.app.path, disableStats: true, authEndpoint: '/{{ request()->path() }}/auth', auth: { diff --git a/src/Dashboard/Http/Controllers/ShowDashboard.php b/src/Dashboard/Http/Controllers/ShowDashboard.php index 5e04c7a..101cfb1 100644 --- a/src/Dashboard/Http/Controllers/ShowDashboard.php +++ b/src/Dashboard/Http/Controllers/ShowDashboard.php @@ -11,6 +11,7 @@ class ShowDashboard { return view('websockets::dashboard', [ 'apps' => $apps->all(), + 'port' => config('websockets.dashboard.port', 6001), ]); } }