I had the same issue with reverb on the production server when I used the deployer. My .env was added to the project after building the js. Please make sure that .env is available before you do yarn build, you can add console.log(import.meta.env) before new Echo() to see all params.
Issues with Reverb, React, and Inertia SSR
Ok so as the title suggests, I'm trying to get Reverb, Inertia SSR + React all talking nice to each other. In local development, everything works great, which is why I note the SSR setup in staging/prod.
As per the docs, I have the following in my bootstrap.js file:
import Echo from "laravel-echo";
import Pusher from "pusher-js";
window.Pusher = Pusher;
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,
wssPort: import.meta.env.VITE_REVERB_PORT,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https",
enabledTransports: ["ws", "wss"],
});
But also as per the docs, the bootstrap.js file is only imported in the app.jsx file, not in the ssr.jsx one.
When I browse to the copy of the hosted site, my browser console says this: Uncaught You must pass your app key when you instantiate Pusher.
I've made sure that the requisite environment variables are present in the .env file and that I've cleared the config cache and rebuilt the assets multiple times, so I don't think it's anything super simple like that.
If anyone has any suggestions for things to try, I'm all ears.
Please or to participate in this conversation.