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

OPTIONS causes 400 in Firefox and IE10 #288

Closed
awdrius opened this issue Oct 2, 2014 · 5 comments
Closed

OPTIONS causes 400 in Firefox and IE10 #288

awdrius opened this issue Oct 2, 2014 · 5 comments

Comments

@awdrius
Copy link

awdrius commented Oct 2, 2014

Hi,

after upgrading socket.io to 1.1.0 Firefox and IE10 started complaining about CORS. The quick fix for the issue was to change engine.io/lib/server.js on line 125:
from
if ('GET' != req.method)
to
if ('GET' !== req.method && 'OPTIONS' !== req.method)

I know that this is not optimal but it works for me.

P.S. I'm using pure socket.io, without express, restify, etc. If there is a better or a standard way to deal with this - your help is much appreciated.

@mokesmokes
Copy link
Contributor

The best way to deal with it is to first figure out why you're generating OPTIONS requests. Do your best to eliminate them.

@awdrius
Copy link
Author

awdrius commented Oct 2, 2014

If I use socket.io client for the website, isn't OPTIONS a mandatory request that browsers issue for the cross domain preflights?
E.g. https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests

@mokesmokes
Copy link
Contributor

You normally want to make sure you're generating only "simple requests". Preflighted requests are slower for the client and increase the load on the server. Avoid them if you can... I'm also running in a CORS scenario and making sure to generate only simple requests.

@awdrius
Copy link
Author

awdrius commented Oct 2, 2014

Unfortunately it is not possible as the API is accessed though multiple request channels and is exposed as a separate subdomain.

I think that a setting to allow OPTIONS preflight request to be handled by engine.io through socket.io (or other) would make sense. It looks like there a plenty of devs out there who are burned by this after upgrading their libraries. A note in documentation with potential workaround(s), explanation, etc. would help. There's nothing worse than trying to make something work and have no idea what's wrong (-.

[Edit] Explanation of "simple request" for those who might use it as a fix: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

@darrachequesne
Copy link
Member

Closed as duplicate of #279

darrachequesne pushed a commit that referenced this issue May 8, 2020
polling-jsonp: prevent spurious errors from being emitted when the window is unloaded
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

3 participants