-
Notifications
You must be signed in to change notification settings - Fork 564
[bug] CORS headers are not following specification #281
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
Comments
As per comments in socketio/socket.io#1778 I will provide PR based on 403 response code and not setting CORS headers at all |
@akamensky your PR #282 will cause this issue to reopen: #211 |
@mokesmokes From #211 it looks like this piece of code was made for the purpose of only easier debugging, while by introducing this code it in fact broke CORS specifications. IMO debugging of any application should not be done using CORS. It can be done from same domain. The sole purpose of If it is really necessary to give ability to put this header even for not allowed domain - this can be done as optional debugging mode and leave standard (production) mode to follow specifications. |
@akamensky no, the purpose is not necessarily just for debugging. If a client makes a request which is valid from an origin standpoint, but invalid from an engine.io protocol standpoint (could happen in production due to many reasons), he should get a 4XX error and not get a response with screwed up CORS headers which will not enable the client app to understand the true nature of the error (which is what #211 complained about). If the CORS headers are wrong the engine.io error is not even seen by the client app (blocked by the browser). |
@mokesmokes Thanks for clarification. I agree that in case request coming from actually allowed origin must not get that response. For such request headers should be set correctly. However I believe that in such situations function of processing error and setting CORS headers should not be combined in one (which as it seem is the case here). CORS headers is a one things and processing error is completely different. I guess most correct approach is to move CORS headers handling into engine.io completely (as you proposed) and same time split headers setting and error processing into two separate functions. I can look into that, however this will also take time as two packages need to be changed together to fix this thing. |
@akamensky whether to check CORS and protocol in one function or two is a matter of style. But the essence is the same: the request must be verified on both issues. Note it's not a "processing" issue but a protocol issue - e.g. |
I am closing this as it seems no agreement is reached without potentially breaking something. Unless something is specifically broken here that we need to fix, I don't see an issue. |
[fix] new XMLHttpRequest always returns an object
This is copy of socketio/socket.io#1778
In my code:
If I do request from
http://b.local:80
, the response headers are:Which is wrong because Origin header tells us that we actually are allowed there. This is also incorrect from specification point of view.
From www.w3.org:
Same time the standard does not specify response code.
Possible solution:
Access-Control-Allow-Origin: null
(as per specs), or completely drop CORS headers as it will trigger browser to display console error of missing header (latter is my preferred option)400 Bad Request
to403 Forbidden
as it more precisely reflects actual status of response (request itself may be not _bad_, but it is not allowed there).Please vote if you agree and I will provide PR for this issue.
The text was updated successfully, but these errors were encountered: