1 year agoby Bhagyaraj Aj
Hi, I had done a simple chat application with laravel Websockets In local it runs super cool. But when i tried to run on HEROKU,it shows access-control-allow-origin CORS policy
Access to XMLHttpRequest at 'http://sockjs.pusher.com/pusher/app/anyKey/2/7c6ekuks/xhr?protocol=7&client=js&version=4.3.1&t=1551116387163&n=24' from origin 'http://mysterious-beach-46504.herokuapp.com' 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.
And i wrote the middleware to access headers that I learned from your tutorial.But it cant be solved and showing the same issue.
Yes this is related to CORS ( cross origin resource sharing).
This is common if you are requesting something ( generally via ajax (XHR ) request ).
It is actually for security reason so that no domain can request something from your site.
To solve it on your server you can install a cors package. I am listing two great package and you can choose any one.
Hope this will solve your problem.