Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross Origin Problem #39

Open
fjcaetano opened this issue Nov 6, 2012 · 4 comments
Open

Cross Origin Problem #39

fjcaetano opened this issue Nov 6, 2012 · 4 comments

Comments

@fjcaetano
Copy link

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.

@mariodev
Copy link

mariodev commented Nov 9, 2012

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

@fjcaetano
Copy link
Author

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

@nanonyme
Copy link
Contributor

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.

@alexandervlpl
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants