如何配置Laravel -websockets包与从子目录,即https://laravel-apps.test/app



我有服务器,我从子目录如https://laravel-apps.test/app1服务Laravel应用程序。它抛出这个错误WebSocket connection to 'wss://laravel-apps.test:6001/app/Kfjaina1m7?protocol=7&client=js&version=7.0.3&flash=false' failed:.

它工作,如果我直接服务的应用程序,如https://laravel-app1.test。我肯定我错过了什么,但我不知道是什么?可能上面的URL在连接时也应该包含子目录字符串,但我不知道如何改变。

任何帮助将非常感激,谢谢!:)

app.js

window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
forceTLS: true,
disableStats: true,
});

config/broadcasting.php

'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => '127.0.0.1',
'encrypted' => false,
'port' => 6001,
'scheme' => env('HTTP_SCHEME', 'http')
]
],

在安全环境下,你必须在broadcast.php中使用https模式,并在websockets.php配置文件中添加证书。

最新更新