django-socketio icon indicating copy to clipboard operation
django-socketio copied to clipboard

Cross Origin Problem

Open fjcaetano opened this issue 12 years ago • 4 comments

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.

fjcaetano avatar Nov 06 '12 17:11 fjcaetano

maybe you should look for some Access-Control-Allow-Origin django middleware..

mariodev avatar Nov 09 '12 13:11 mariodev

Ok, but how do I tell django-socketio to use this middleware?

fjcaetano avatar Nov 12 '12 19:11 fjcaetano

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.

nanonyme avatar Apr 16 '13 08:04 nanonyme

Got the example running by installing and configuring django-cors-headers: pip install django-cors-headers.

alexandervlpl avatar Sep 01 '15 14:09 alexandervlpl