This is a repost form this Github issue : https://github.com/rails/rails/issues/11380
I would like to have your opinion about the following :
When sending an AJAX request, one expect
request.xhr? to return
true, but this is not true when using jQuery and CORS. This problem is caused by the fact jQuery decided to not automatically send
X_HTTP_REQUESTED_WITH header for CORS requests (see. http://bugs.jquery.com/ticket/8423).
I think every CORS requests should be considered as XHR requests. And I would advocate updating
ActionDispatch::Request#xhr? to return true for every CORS requests. This might be implemented by detecting presence of
Origin header (and maybe checking
Do you see any use-case where CORS requests would not be XHR requests or any other issue with this proposal ?