I'm assembling my first AngularJS app. My controller is making a $http.get() call. The url it's using is correct, but it ends up calling the "error" method with a 404. This is even more confusing when I see the URL being requested in Firebug, and it reports a 200.
I don't think I need to show the html for this. I can't imagine how that could be relevant.
Here's my somewhat elided javascript:
var diagapp = angular.module("DiagApp", ['ui.bootstrap', 'ngResource']);
diagapp.controller("DiagCtrl", ['$scope', '$interval', '$http', function($scope, $interval, $http) {
$http({method:'GET',url:'http://<hostportandpath>/service/diagnostics/datasourceStatus.json'})
.success(function (data, status, headers, config) {
console.log(data);
})
.error(function (data, status, headers, config) {
console.log(data);
});
}]);
I've tried setting a breakpoint at the "$http" line, and then copying and pasting the URL referenced on that line into another browser tab, and it shows me the correct json returned by that service. I then continue from the breakpoint, and it hits the breakpoint in the "error" method, and the status says 404.
What could I be doing wrong?
Update:
I've modified this so that the service call is only relative, so it doesn't violate the CDP.
I also set up a "node express" web server running at the root of my webapp, so it will serve requests for files in the webapp, but any calls to the REST service are 302-redirected to the service on another domain.
When I debug this in Firebug, I see it get the 302, and then I see it get the 200, so it obviously followed the redirect. However, it then hits the breakpoint in the "error" method, still saying it got a 404. In other words, I get the exact same result. I'm befuddled.
Update:
Here is my slightly elided "express server" configuration:
var express = require('express');
var app = express();
app.use("/", express.static(__dirname));
app.use(app.router);
app.get('/FooService/*', function(req, res) {
res.redirect(302, 'http://<hostname>' + req.path);
});
app.listen(8000);
withCredentials:truein the$httpconfig object and it will send an OPTIONS preflight