I am trying to get CORS working with TeamCity but running into all manner of problems. I'm using JQuery in a file served from a local Apache server making REST queries against a TeamCity server which also happens to be local (for the sake of testing), but will eventually be remote.
Even so, I get CORS errors.
In TeamCity, the internal properties show up as
Yet, when I make a request for json, I get an error like
XMLHttpRequest cannot load http://myserver.com:8111/httpAuth/app/rest/builds/?locator=count:10. Origin http://myserver.com is not allowed by Access-Control-Allow-Origin
This request is being made in JQuery GET but is coming through the browser as OPTIONS (because of cors preflight - and here, I'm not sure if it's Chrome, JQuery, or TC where I need to fix things)
If I make the request without the accepts header or an authorization header, the request is an expected GET but fails because of authorization. Using a URL like http://user:firstname.lastname@example.org doesn't work. Nor does JQuery's username/password get successful authorization.
So, I changed things around, I used jsonp with a callback. This actually worked but is returning XML - the application/json header is ignored because of the way jsonp is executed (via an injected SCRIPT block). Is there a way to specify json in the REST URL rather than relying solely on the Accept header?
Any advice or sample code of using CORS correctly to make requests?