beyondcode / laravel-websockets

Websockets for Laravel. Done right.
https://beyondco.de/docs/laravel-websockets
MIT License
5.07k stars 619 forks source link

Access to XMLHttpRequest at ' ... ' from origin ' ... ' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. #384

Closed mdutt247 closed 4 years ago

mdutt247 commented 4 years ago

image

The same error I solved on the local machine by adding 'useTLS' => false, 'encrypted' => false in config/broadcasting.php and forceTLS:false, 'encrypted':false in resources/js/bootstrap.js

When I try to run it on the live server, it gives CORS policy error Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I also tried downgrading pusher.js from 6.0.3 to 4.4 but got no success.

I have hosted this application on shared hosting on Laravel 5.8, and use Cloudflare.

renwarkurd commented 4 years ago

Same issue here

kaikeSilva commented 4 years ago

did you resolve this?

renwarkurd commented 4 years ago

No. I haven't. I ended up not using it unfortunately. Hope you guys find a solution for it.

hassandiv commented 4 years ago

You can fix this URL issue:

Solution: In your post request make sure you have the full URL 'http://sockjs-mt1.pusher.com/pusher/app/....etc'

Error: const siteUrl = 'http://sockjs-mt1.pusher.com/' Post request ${siteUrl}/pusher/app/....etc

allaniftrue commented 4 years ago

same here

natnaelawel commented 4 years ago

same issue here

shaikhfoysal commented 4 years ago

Anyone solve this issue. I have the same problem. enabledTransports: ['ws', 'wss'] I did this but didn't solve the problem. What to do? Local is good but not in the web.

rennokki commented 4 years ago

Duplicate of https://github.com/beyondcode/laravel-websockets/issues/403 (see you there)

pushpendra2636 commented 4 years ago

@ECHO OFF "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp pause

/**** create a new file and save file .bat extension "like this :- privateBrowser.bat" , and run the this file. and insert local path: http://localhost:4200 ***/

ghost commented 4 years ago

i am also getting this error

rennokki commented 4 years ago

Check https://github.com/beyondcode/laravel-websockets/issues/403

ziagit commented 3 years ago

I solved this problem by changing pusher-js version from 6.0.0 to 5.1.1. in (Laravel vuejs project)