Skip to content

Client side link keeps prompting 400 (Bad Request) #3

Description

@cnjackven

After deploying fixed-laravel-echo-server, the client side link keeps prompting 400 (Bad Request), can you help me?

"laravel-echo": "^1.16.1",
"socket.io-client": "^4.7.5",

import Echo from 'laravel-echo'
import io from 'socket.io-client'

window.io = io
window.Echo = new Echo({
  broadcaster: 'socket.io',
  host: 'test.com', 
  auth: {
    headers: {
      Authorization:
        'Bearer request token' 
    }
  }
})
window.Echo.private('im.chat.message.12345').listen('.chat.message', (e) => {
  console.log( e)
})

NGINX server

        #the following would go within the server{} block of your web server config
	location /socket.io {
		proxy_pass http://127.0.0.1:6001; #could be localhost if Echo and NginX are on the same box
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
	}

ERROR:

Access to XMLHttpRequest at 'http://test.com/socket.io/?EIO=3&transport=polling&t=OyJ3I6q' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

[root@test test.com]# curl http://127.0.0.1:6001?EIO=3&transport=polling&t=OyJIoDI
[1] 154304
[2] 154305
[root@test test.com]# {"success":true,"message":"OK","headers":["*/*"]}

clientConnectEndpoint and clientDisconnectEndpoint must be set?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions