How to set Angular JS $resource path (I'm getting 404s here)

I'm a noob to AngularJS and trying to set up a simple webapp in order to test, if the framework suites our needs. I've read the API reference and did the tutorial. Unfortunately the way path and locations are set and handled on $resource is not quite well explained there.

The problem I am facing is that I always get a 404 when I give $resource the relative path as described in the tutorial.

Here is my set up:

I have cloned the AngularJS phone cat app and threw away their phone stuff but made use of their structure to bring in my own logic. My index.html looks as follows:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>testapp</title>
  <link rel="stylesheet" href="css/bootstrap.css">
  <script src="lib/angular/angular.js"></script>
  <script src="lib/angular/angular-resource.js"></script>
  <script src="js/app.js"></script>
  <script src="js/controllers.js"></script>
  <script src="js/filters.js"></script>
  <script src="js/services.js"></script>
</head>
<body ng-app="testapp">
    <div class="navbar">
        <div class="navbar-inner">
            <a class="brand" href="#">Testapp using AngularJS</a>
        </div>
    </div>

    <div ng-view></div>

</body>

First trouble was that AngularJS doesn't seem to give any advice on how to oauth to a RESTful API, and their tutorial only gives a "dream scenario" of a server delivering hard-coded JSON, so I have hacked into their web-server.js in order to let the node.js server handle the API calls and return the resulting JSON. For oauth I did so successfully, yet for further API calls, it doesn't work.

Here's my hack:

StaticServlet.prototype.handleRequest = function(req, res) {
  var self = this;
  var path = ('./' + req.url.pathname).replace('//','/').replace(/%(..)/g, function(match, hex){
    return String.fromCharCode(parseInt(hex, 16));
  });
  var parts = path.split('/');
  if (parts[parts.length-1].charAt(0) === '.')
    return self.sendForbidden_(req, res, path);

  /* Hack for RESTful API calls. */
    var post = '';
    var query = qs.parse(req.url);

    if (req.method === 'POST') {
        var body = '';
        req.on('data', function(data) {
            body += data;
        });
        req.on('end', function () {
            post = JSON.parse(body);
            console.log(post);
            // method name is part of the parameters
            // apiRequests is the module handling the API requests
            apiRequests[post.method](post, res);
        });
    } else if (query.api === 'api') {
        var query = qs.parse(queryString);
        // method name is part of the parameters
        // apiRequests is the module handling the API requests
        apiRequests[query.method](queryString, res);
    } else {
            fs.stat(path, function(err, stat) {
            if (err)
              return self.sendMissing_(req, res, path);
            if (stat.isDirectory())
              return self.sendDirectory_(req, res, path);
            return self.sendFile_(req, res, path);
        });
    }
}

It's really just an ugly hack, but anyways. The login POST request is delegated to an oauth call and the api GET requests are delegated to the proper api request methods, the rest is handled the same way as web-server.js did before.

The trouble is, the handleRequest method is never called.

Here is my client side service code making the call:

return {
        fetchCommunications : function ($scope) {
            var parameters = {
                'api': 'api',
                'method': 'communications',
                'bearer':userData["access_token"],
                'chiffre':userData["chiffre"]
            }
            var resource = {
                r : $resource('communications', {}, {
                    query: {method:'GET', params:parameters}
                })
            }
            var d = resource.r.query();
            console.log("Communications: " + d);
            return d;
}

And this is the error message from the server console:

GET /app/communications?api=api&bearer=d6a348ea-0fe5-46fb-9b5e-13d3343c368d&chiffre=0000006F&method=communications Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
404 Not Found: /app/communications

This is exactly the path I'd expect to be called - but why is it 404?

I can avoid the 404 by configuring $resource like this:

var resource = {
    r : $resource('index.html#/communications', {}, {
    query: {method:'GET', params:parameters}
})

Which doesn't work either, since everything after the hash is omitted from the path. Besides, why would I need to have index.html within the path?

I have the feeling that I am missing something pretty obvious here and am therefore doing something pretty dumb. Anyone with any ideas? Is it something related to the configuration of node.js (never had this trouble before)?

Many thanks in advance!