laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.54k stars 11.02k forks source link

Getting X-Socket-Id JS error after axios version bump #41854

Closed kikky7 closed 2 years ago

kikky7 commented 2 years ago

Description:

I am upgrading JS packages on my app (mix, webpack, purge and other stuff, which works great so far), but when I update axios from v0.18 to v0.21 (used with Laravel v8..6.11) or v0.25 (used in latest Laravel version) I get this error "Cannot set properties of null (setting 'X-Socket-Id')". I am posting this here because I don't think it's axios issue, since this is connected with Laravel Echo afaik.

Steps To Reproduce:

When I downgrade axios to v0.18 it works, but since there are some known security issues in v0.18 fixed in v0.21 I want to use at least that version (if not the latest). All issues regarding x-socket-id are several years old and I couldn't find any working solution.

This is my bootstrap.js file where Echo and axios are defined:

window._ = require('lodash');

window.moment = require('moment');

window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').content;

window.Pusher = require('pusher-js');

import Echo from 'laravel-echo';
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'my-pusher-key',
    cluster: 'eu'
});
driesvints commented 2 years ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.