redroseamit liked a comment+100 XP
1d ago
Hello,
Here is my .env file.
REVERB_APP_ID=my-app-id
REVERB_APP_KEY=my-app-key
REVERB_APP_SECRET=my-app-secret
REVERB_HOST=localhost
REVERB_PORT=8080
REVERB_SCHEME=http
VITE_REVERB_APP_KEY=${REVERB_APP_KEY}
VITE_REVERB_HOST=${REVERB_HOST}
VITE_REVERB_PORT=${REVERB_PORT}
VITE_REVERB_SCHEME=${REVERB_SCHEME}
And here my app.js file.
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'],
});
And it works fine.
Just follow the Laravel documentation.
redroseamit started a new conversation+100 XP
1d ago
import 'bootstrap';
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
import Pusher from 'pusher-js';
import 'bootstrap';
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
import Pusher from 'pusher-js';
const BASE = 'http://localhost/ecart/prd';
const CSRF = document.querySelector('meta[name="csrf-token"]')?.content || window.App?.csrfToken;
console.log('🔥 CSRF USED:', CSRF);
window.pusher = new Pusher(import.meta.env.VITE_REVERB_APP_KEY, {
wsHost: window.location.hostname,
wsPort: 8080,
wssPort: 8080,
forceTLS: false,
enabledTransports: ['ws'],
cluster: 'mt1',
disableStats: true,
authEndpoint: '/broadcasting/auth',
auth: {
headers: {
'X-CSRF-TOKEN': CSRF,
'X-Requested-With': 'XMLHttpRequest'
}
},
withCredentials: true
});
``` i a m using xamp server getting below error
chat.js:203 ❌ [Chat] Subscription error for private-chat.chat_test_1777144082 {type: 'AuthError', error: 'Unable to retrieve auth string from channel-author…r.com/docs/channels/server_api/authorizing-users/', status: 403}