问题描述 投票:0回答:1

import axios from "axios"; window.axios = axios; window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest"; /** * Echo exposes an expressive API for subscribing to channels and listening * for events that are broadcast by Laravel. Echo and event broadcasting * allow your team to quickly build robust real-time web applications. */ import "./echo"; import "./erp_echo"; import "./seller_echo";

Resources/js/echo.js

import Echo from "laravel-echo"; import Pusher from "pusher-js"; window.Pusher = Pusher; console.log(import.meta.env.VITE_REVERB_HOST); window.Echo = new Echo({ broadcaster: "reverb", key: import.meta.env.VITE_REVERB_APP_KEY, wsHost: import.meta.env.VITE_REVERB_HOST, wsPort: import.meta.env.VITE_REVERB_PORT ?? 80, wssPort: import.meta.env.VITE_REVERB_PORT ?? 443, forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https", enabledTransports: ["ws", "wss"], });
Resources/js/erp_echo.js

import Echo from "laravel-echo"; import Pusher from "pusher-js"; window.Pusher = Pusher; console.log(import.meta.env.VITE_REVERB_HOST); window.ErpEcho = new Echo({ broadcaster: "reverb", key: import.meta.env.VITE_REVERB_APP_KEY, wsHost: import.meta.env.VITE_REVERB_ERP_HOST, wsPort: import.meta.env.VITE_REVERB_PORT ?? 80, wssPort: import.meta.env.VITE_REVERB_PORT ?? 443, forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https", enabledTransports: ["ws", "wss"], });

Resources/js/seller_echo.js
import Echo from "laravel-echo";

import Pusher from "pusher-js";
window.Pusher = Pusher;
console.log(import.meta.env.VITE_REVERB_HOST);
window.SellerEcho = new Echo({
    broadcaster: "reverb",
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_SELLER_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https",
    enabledTransports: ["ws", "wss"],
});

如何确保混响可以与Laravel 11中的主要领域和子域一起使用?预先感谢
I在Laravel 11中使用Reverb在主要域和子域设置了Websocket,但它不起作用。
    

我有类似的问题,我发现了解决方法。 因此,我的Laravel Project(带有React和TypeScript的惯性)托管在主域“ Maindomain.com”上的Hostinger VPS服务器上。 Reverb在此服务器上工作正常。为此的配置是:

.env

maindomain.com

BROADCAST_CONNECTION=reverb
REVERB_APP_ID=your.reverb.app.id
REVERB_APP_KEY=your.reverb.app.key
REVERB_APP_SECRET=your.reverb.app.secret
REVERB_HOST=your.main.server.host # for Hostinger something like abc123456.hstgr.cloud
REVERB_PORT=8081
REVERB_SERVER_PORT=8082
REVERB_SCHEME=https

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

-Hostinger VPS CloudPanel的Vshost(NGINX),最后一个新服务器块:

server { listen 8081 ssl; listen [::]:8081 ssl; {{ssl_certificate_key}} {{ssl_certificate}} server_name abc123456.hstgr.cloud maindomain.com; location / { proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header SERVER_PORT $server_port; proxy_set_header REMOTE_ADDR $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_pass http://0.0.0.0:8082; } }

vuejs3 laravel-11 laravel-reverb
1个回答
0
投票
.env

REVERB_APP_ID=your.reverb.app.id REVERB_APP_KEY=your.reverb.app.key REVERB_APP_SECRET=your.reverb.app.secret REVERB_HOST=your.main.server.host # SAME AS IN maindomain.com .env REVERB_PORT=8083 REVERB_SERVER_PORT=8084 REVERB_SCHEME=https VITE_REVERB_APP_KEY="${REVERB_APP_KEY}" VITE_REVERB_HOST="${REVERB_HOST}" VITE_REVERB_PORT="${REVERB_PORT}" VITE_REVERB_SCHEME="${REVERB_SCHEME}"

现在,当我们将配置服务器添加到Maindomain.com的MAINDOMAIN的VHOST中时

server { listen 8083 ssl; listen [::]:8083 ssl; {{ssl_certificate_key}} {{ssl_certificate}} server_name abc123456.hstgr.cloud maindomain.com; location / { proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header SERVER_PORT $server_port; proxy_set_header REMOTE_ADDR $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_pass http://0.0.0.0:8084; } }
以后:

togo到达终端
sudo systemctl restart nginx

(作为root用户)

Go到子域项目(sub-user@abc123456:〜/htdocs/sub.maindomain.com $)

php artisan config:clear

npm run build

  • exit
  • (root用户)
  • sudo systemctl restart supervisor
  • 这为我工作。希望它能帮助他人。 如果您找到其他解决方案,请发布以帮助其他解决方案。
    	
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.