django-socketio
django-socketio copied to clipboard
Cross Origin Problem
Hey guys, I'm having trouble to run my server correctly.
I'm running my django server through the port 8088 and the socketio server in the port 9000. My connections are being logged in the socketio correctly:
"127.0.0.1 - - [2012-11-06 15:15:05] "GET /socket.io/websocket HTTP/1.1" 500 52474 0.120885 127.0.0.1 - - [2012-11-06 15:15:10] "GET /socket.io/xhr-polling//1352222110658 HTTP/1.1" 500 50095 0.051357"
But Chrome is having a cross origin problem:
"XMLHttpRequest cannot load http://localhost:9000/socket.io/xhr-polling//1352221950619. Origin http://localhost:8088 is not allowed by Access-Control-Allow-Origin."
So, please, I need some help to solve this.
Probably it's as simple as telling my SocketIO server too allow connections from anywhere, but I couldn't figure it out.
maybe you should look for some Access-Control-Allow-Origin django middleware..
Ok, but how do I tell django-socketio to use this middleware?
I'd probably write the headers to requests using nginx. It's really simple to do there. Then again, nginx older than 1.3 don't support Websockets yet.
Got the example running by installing and configuring django-cors-headers: pip install django-cors-headers
.