I am building an application based on Backbone.js and am facing some strange problem.
At some point, the application requests a collection resource, and inside Chrome (and Safari) I get this error:
XMLHttpRequest cannot load http://api.mydomain.net/v1/foos/00000d/bars/000014/boots Origin http://localhost:3501 is not allowed by Access-Control-Allow-Origin.
Ok, CORS problem, I thought and blamed my API. Then I requested this same resource through CURL:
curl -i -H'Accept: application/json' -H'X-Auth-Token: pAWp5hrCmXA83GgFzgHC' -XOPTIONS 'http://api.mydomain.net/v1/foos/00000d/bars/000014/boots' HTTP/1.1 200 OK Status: 200 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST, GET, OPTIONS Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Auth-Token Content-Length: 0
looks good, now get:
curl -i -H'Accept: application/json' -H'X-Auth-Token: pAWp5hrCmXA83GgFzgHC' -XGET 'http://api.mydomain.net/v1/foos/00000d/bars/000014/boots' HTTP/1.1 204 No Content Status: 204 Cache-Control: no-cache Content-Length: 0 Content-Type: text/plain
In case I request a boots collection that contains at least one object, everything works fine. The CORS headers on my server respond perfectly to arr as I think. So why do browsers report a cross-source issue?
Is this related to the text/plain content type of my 204 responses?
Preflight request (OPTIONS) in dev tools: 
Request interrupted response headers: 