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
This commit is contained in:
Henrik B Hansen 2019-09-04 08:48:06 +02:00 committed by Marcel Pociot
parent fa86844ea5
commit 8e422cbc5b
3 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,13 @@ use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
return [ 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 * This package comes with multi tenancy out of the box. Here you can
* configure the different apps that can use the webSockets server. * configure the different apps that can use the webSockets server.
@ -20,6 +27,7 @@ return [
'name' => env('APP_NAME'), 'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'), 'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null, 'capacity' => null,
'enable_client_messages' => false, 'enable_client_messages' => false,
'enable_statistics' => true, 'enable_statistics' => true,

View File

@ -95,8 +95,8 @@
connected: false, connected: false,
chart: null, chart: null,
pusher: null, pusher: null,
port: 6001,
app: null, app: null,
port: {{ $port }},
apps: {!! json_encode($apps) !!}, apps: {!! json_encode($apps) !!},
form: { form: {
channel: null, channel: null,
@ -114,8 +114,9 @@
connect() { connect() {
this.pusher = new Pusher(this.app.key, { this.pusher = new Pusher(this.app.key, {
wsHost: this.app.host === null ? window.location.hostname : this.app.host, wsHost: this.app.host === null ? window.location.hostname : this.app.host,
wsPort: this.port, wsPort: this.port === null ? 6001 : this.port,
wssPort: this.port, wssPort: this.port === null ? 6001 : this.port,
wsPath: this.app.path === null ? '' : this.app.path,
disableStats: true, disableStats: true,
authEndpoint: '/{{ request()->path() }}/auth', authEndpoint: '/{{ request()->path() }}/auth',
auth: { auth: {

View File

@ -11,6 +11,7 @@ class ShowDashboard
{ {
return view('websockets::dashboard', [ return view('websockets::dashboard', [
'apps' => $apps->all(), 'apps' => $apps->all(),
'port' => config('websockets.dashboard.port', 6001),
]); ]);
} }
} }