0

I'm studying Laravel real time, and I want to provide the frontend websockets url, but I'm not sure how to do so. Could you please help me? Am I doing something incorrectly? Is there any git repos i can learn?

I'm using BROADCAST_DRIVER=pusher to run my websocket server in local. I ran this url to connect websocket "http://127.0.0.1:8000/laravel-websockets" I also connected with React js too using socket.io but there's error . "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:6001/socket.io/?EIO=4&transport=polling&t=P0Bfm60. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 404." I've config in middleware, config.cors in laravel but it still show this error.

4
  • You can't use the socket.io client to connect to a pusher server, socket.io has a "protocol" which your server should implement and in this case it is not, here is how you should use it pusher.com/tutorials/web-notifications-laravel-pusher-channels/… Commented Jun 12, 2024 at 9:12
  • thank you. i want to intergrate it with frontend framework like react js by provide api for them is there any document i can read? Commented Jun 12, 2024 at 9:17
  • You don't need a special library for react, you can just use it normally, here is an example of that, but it can change based on your structure and requirements pusher.com/tutorials/react-websockets/… Commented Jun 12, 2024 at 10:32
  • thank you so much! is there anyway i can publish my laravel websockets url without using pusher? Commented Jun 15, 2024 at 3:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.