Laravel 本地开发 wss 连接配置
laravel-echo-server.json
{
"authHost": "https://localhost",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "your-app-id",
"key": "your-app-key"
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": "localhost",
"port": "6001",
"protocol": "https",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "/path/to/your/ssl/cert.pem",
"sslKeyPath": "/path/to/your/ssl/key.pem",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": "https://localhost",
"allowMethods": "GET, POST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, Authorization, Accept, Accept-Language, X-Requested-With"
}
}
本地开发使用 wss 连接,需要手动配置一下 sslCertPath
和 sslKeyPath
,使用 valet
本地站点证书的路径就可以了,其他的把 allowOrigin
、authHost
改一下,剩下的不用动。
放到项目根目录,并在 .gitignore
中忽略该文件。
:sweat_smile: 好像说了 又好像什么都没说
实际上只要redis配置对了就问题不大