Cross origin request blocked Pubnub

1.3k views Asked by At

I am making a chat app and i am getting these errors (quite a few of them) Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at http://ps1.pubnub.com/subscribe/sub-c-43a257e0-d94a-11e4-a2b8-0619f8945a4f/my_channel%2Cmy_channel_resent/0/0?uuid=%20User%20Spyros%20with%20number%2080%20has%20come%20online%20&pnsdk=PubNub-JS-Web%2F3.6.7. (Reason: CORS request failed).

I literally do not know what to do, any ideas??

2

There are 2 answers

2
Bhavana On

On PubNub’s network, the way data is sent and received on long-lived TCP socket connections, but with a browser, they expect to have special headers, otherwise known as CORS headers to allow certain resources over that connection. If a CORS header is excluded from the payload on a response, an error is thrown in the browser.

These occur when a TCP socket is severed through the browser. Essentially what’s occurring is that the browser notices that it’s missing a CORS header, so no data is coming down the pipe. What really should be happening is the browser should give a TCP socket error saying ‘severed’ or ‘aborted’, but it’s been implemented to deliver a CORS error.

What you really want to look out for is data loss, and if you are, please contact [email protected]!

0
girlie_mac On

PubNub does support CORS.

Are you on Firefox? Some people see the issue on FF when running a local server, but rebooting the browser often solves the case.

See: Firefox CORS request giving 'Cross-Origin Request Blocked' despite headers