This is a module specific question: you should search in the socket.io docs 
how to enable cross domain connections.

Background of such 
mechanism: http://en.wikipedia.org/wiki/Same_origin_policy



Am Montag, 11. Februar 2013 13:48:29 UTC+1 schrieb Mustafa Özyurt:
>
> Hey,
>
> Im using this code to prevent cross-domain access to my server.js.
>
> But even-tho server.js and wp.html files at the same host its not working. 
>
> Here is the given warning...
>
> info  - socket.io started
> debug - served static content /socket.io.js
> debug - authorized
> warn  - handshake error Cross-domain connections are not allowed
>
>
> server.js
>
> -------------------------------------------------------------------------------------------
> var io = require('socket.io').listen(3000);
>
> io.configure(function() {
>    io.set('authorization', function (handshakeData, callback) {
>        if (handshakeData.xdomain) {
>            callback('Cross-domain connections are not allowed');
>        } else {
>            callback(null, true);
>        }
>    }); 
> });
>
>
> io.sockets.on('connection', function (socket) {
>     socket.on('message', function (message) {
>         console.log("Got message: " + message);
>         io.sockets.emit('pageview', {'url': message});
>     });
>
> });
>
>
> wp.html
>
> -------------------------------------------------------------------------------
> <html>
> <body>
> <h1>Simple Page</h1>
> <script type="text/javascript" src="
> http://222.222.222.222:3000/socket.io/socket.io.js";></script>
> <script>
>     var socket = io.connect('http://222.222.222.222:3000');
>     
>     socket.on('error', function (reason){
>         console.error('Unable to connect Socket.IO', reason);
>     });
>     
>     socket.on('connect', function () {
>         socket.send(window.location);
>     });
> </script>
> </body>
> </html>
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to