Laravel-websockets: 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.

Created on 26 May 2020  路  12Comments  路  Source: beyondcode/laravel-websockets

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.

Most helpful comment

@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
**/

All 12 comments

Same issue here

did you resolve this?

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

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

same here

same issue here

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.

@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
**/

i am also getting this error

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

Was this page helpful?
0 / 5 - 0 ratings