-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
CORS Errors after updating to 2.2.0 #3381
Comments
+1 Started to fail since I downloaded the packages again. |
Workaround: npm install socket.io@2.1.1 |
The funny thing is that I'm using a custom origins callback and it returns "*" as allowed origin instead of the actual origin passed from the client when the callback is called with success set to true. |
Hmm.. I don't see anything related in the changelog... It may be the update of the Is anyone able to reproduce the issue? |
Yes. You need to have socket server on separate domain. |
@darrachequesne : I updated my description with a link to repo where you can reproduce the issue. Instructions are in the README at the repo. |
@darrachequesne It seems like if you comment out these lines in if ('withCredentials' in xhr) {
xhr.withCredentials = true;
} then the requests succeed. So maybe, in v <2.2.0, somehow |
@sjones6 thanks for the repo. What I don't understand is that your example is a basic CORS situation, where the client is served from a location ( |
I think with credentials was always set to true. The problem is that allow origins * is not allowed when with credentials is set to true. Previous versions would use the client origin (or referer if missing) header when an origin was valid, but the new version just uses "*", and therefore the browser complains. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials |
@flenter could it be related to socketio/engine.io#511? |
Another option is of course to set with credentials to false, but that'd mean that the socket io server does not care about getting / setting any cookies. Not sure if that's the case with socket io |
That pr could have added a way to set the header to the client request origin header. Maybe a good place to do this is that when using origins with a callback and the callback is called with success true the Allow-origins would be set to the origin that was passed to the callback. Either way, after that PR this is a breaking change though I guess? As it is right now I see no way to support all origins when with credentials is set to true |
…511) This reverts commit ebf1a96. Related: socketio/socket.io#3381
I reverted the PR and published a new version of |
Or to avoid a breaking change then when origins is not explicitly set in the options / set to undefined (default) or origins function is called with undefined then it will use the client origin header (the old default behavior) |
Wouldnt it make sense to have credentials off by default? For most cases it shouldnt be on anyway right? |
@darrachequesne : Thanks; we've pulled down 3.3.2 of Based on this comment this comment from @xaviergonz , I think I have a clearer picture: In I'm all for enforcing CORS as default behavior ... but seems like that's probably a breaking change that should be added in new major version. latest edit to correct errant version number of engine.io. |
Is there any ETA on bug fix release? 2.2.0 uses engine 3.3.1, not 3.3.2 |
@neemah i had to remove and add socket.io to have the updated version : here my yarn list now : |
Well @ravid87,3.3.1 engine.io is "broken", while 3.3.2 is fixed :) |
@neemah the broken one was 3.2.2
|
@ravid87 3.2.2 doesn't exist https://github.com/socketio/engine.io/tree/3.2.2, so i assume author of message meant 3.3.2, which is latest release, if you check commits / tags. So still waiting for fix :) |
@neemah @ravid87 : sorry for confusion; correcting my typo by editing comment ... |
@neemah :
You need to delete your package-lock.json (or yarn.lock) first though before installing of you'll get |
@sjones6 ok thx for the version correction. But i'm still confused because,
socket.io@^2.2.0:
|
2 - probably because you are checking it on same domain, where this problem does not appear |
@neemah here my setup : so its not on same domain :/ |
then probably you configurated origin with value |
@neemah no origins configured on socket.io or express.js. i had CORS problem yesterday and today after a clean install of socket.io everything worked again... |
@ravid87 : Can you confirm today you have
|
@sjones6 yes ! i have the 3.3.2 👍 thx for the clarification :) |
I Have same problem with CORS:
|
Having the same problem as @AhCamargo responded, with the same versions of socket.io and engine.io, but mine is that I'm trying to open a socket.io connection with auth from a different domain (client side) than the server side Full error context: Server side versions:
Client side versions:
The server side:
Here's the interesting bits I debugged: Removing auth middleware from socketio in server side -
Makes the connection work fine. I can see the error log in nginx as the following:
curl gives me:
Which is in accordance with the explanation here: https://stackoverflow.com/a/52048304/11626829 Basically the browser is sending the options pre-flight request, but that is taken up by socket.io as a handshake request. |
I have same issue..
It works fine when I send it with query params:
|
I have same issue.. |
For future readers: this was fixed in Please see the documentation here: https://socket.io/docs/v3/handling-cors/ |
You want to:
Current behaviour
Getting lots of CORS errors after the latest update.
Steps to reproduce (if the current behaviour is a bug)
Repo. See README for instructions.
Expected behaviour
No CORS errors.
Setup
Other information (e.g. stacktraces, related issues, suggestions how to fix)
@davericher made a comment here indicating this. Perhaps he has more details.
The text was updated successfully, but these errors were encountered: