Cross-Origin Request Blocked: The Same Origin Poli

2019-01-12 02:12发布

I'm using CometChat in my website and recently my users art having this problem with receiving messages. After inspection in FireBug i realized it must be because of the CORS protection (due to the following error) that the script is failing.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://x3.chatforyoursite.com/subscribe/... This can be fixed by moving the resource to the same domain or enabling CORS.

Now I'm wondering where should I enable CORS because it is enabled on my own server and I have no access to the CometChat server.

3条回答
该账号已被封号
2楼-- · 2019-01-12 02:27

The server at x3.chatforyoursite.com needs to output the following header:

Access-Control-Allow-Origin: http://www.example.com

Where http://www.example.com is your website address. You should check your settings on chatforyoursite.com to see if you can enable this - if not their technical support would probably be the best way to resolve this. However to answer your question, you need the remote site to allow your site to access AJAX responses client side.

查看更多
霸刀☆藐视天下
3楼-- · 2019-01-12 02:27

The use-case for CORS is simple. Imagine the site alice.com has some data that the site bob.com wants to access. This type of request traditionally wouldn’t be allowed under the browser’s same origin policy. However, by supporting CORS requests, alice.com can add a few special response headers that allows bob.com to access the data. In order to understand it well, please visit this nice tutorial.. How to solve the issue of CORS

查看更多
倾城 Initia
4楼-- · 2019-01-12 02:47

For simple GET request your can use a proxy server like https://bypasscors.herokuapp.com/

查看更多
登录 后发表回答