Browse Source

Remove X-Requested-With header to avoid CORS preflight requests

Thibaut Courouble 8 years ago
parent
commit
786a549f0f
1 changed files with 0 additions and 6 deletions
  1. 0 6
      assets/javascripts/lib/ajax.coffee

+ 0 - 6
assets/javascripts/lib/ajax.coffee

@@ -75,9 +75,6 @@ applyHeaders = (xhr, options) ->
   if options.dataType
   if options.dataType
     options.headers['Accept'] = MIME_TYPES[options.dataType] or options.dataType
     options.headers['Accept'] = MIME_TYPES[options.dataType] or options.dataType
 
 
-  if isSameOrigin(options.url)
-    options.headers['X-Requested-With'] = 'XMLHttpRequest'
-
   for key, value of options.headers
   for key, value of options.headers
     xhr.setRequestHeader(key, value)
     xhr.setRequestHeader(key, value)
   return
   return
@@ -111,9 +108,6 @@ abort = (xhr) ->
   xhr.abort()
   xhr.abort()
   return
   return
 
 
-isSameOrigin = (url) ->
-  url.indexOf('http') isnt 0 or url.indexOf(location.origin) is 0
-
 parseResponse = (xhr, options) ->
 parseResponse = (xhr, options) ->
   if options.dataType is 'json'
   if options.dataType is 'json'
     parseJSON(xhr.responseText)
     parseJSON(xhr.responseText)