Angular $http.post being seen as GET request to remote rails server

Hi All - I’m currently working on an app which uses a JSON post request to a remote server once the device is registered for push notifications. Since it involves push notifications, and potential CORS issues, I have to use xcode and my phone for testing for this, unfortunately :frowning:

Anyway, I’m having issues with angular $http.post to create a “user” with JSON data. I’m posting to a remote heroku rails server, which is being returned with a 404 status. But, the server logs claims it’s coming in as a GET request, and thus recognizing it as a request for index.

Here’s my current angular code which results in the 404 (I also tried the $http.post with the same result):

var user = { "user": { token: $scope.regId } };
var req = {
 method: 'POST',
 url: 'http://my-app.heroku.com/users.json',
 dataType: "json",
 headers: {
   'Content-Type': 'application/json'
 },
 data: user,
}

And here is my rake routes result on the server:

users GET    /users(.:format)            users#index
          POST   /users(.:format)        users#create

And here is the result in the server log:

2015-01-03T03:10:02.586430+00:00 app[web.1]: Started GET "/users.json" for 108.219.94.106 at 2015-01-03 03:10:02 +0000
2015-01-03T03:10:02.590083+00:00 app[web.1]:
2015-01-03T03:10:02.590086+00:00 app[web.1]: AbstractController::ActionNotFound (The action 'index' could not be found for UsersController):

Does anyone have an idea why this request ends up sent as a get? Or if the JSON isn’t being sent at all?

And/or any debugging tips through the xcode console would be greatly appreciated, I’m not doing so well without my usual chrome tools :frowning:

Thanks!!

Just in case anyone else has this problem - I finally backed up and got CORS working, but it turns out for heroku when you’re doing something other than GET you need to go to mydomain.herokuapps.com (not just mydomain.heroku.com) It’s possible that it started working from getting CORS working, but if anyone’s trying to just get it working direct from the device, I’d try using herokuapps first.