I did a simple node server , which I need it to be Cross Origin for $http.get()
calling , so I add the required headers to the app.use
as details in this answer. Finally the server code is -
var express = require('express');
var app = express();
var port = process.env.PORT || 3000;
app.use(express.static('.'));
app.all('/', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
app.listen(port);
console.log('server runs on port: ' + port);
In my index.html
there is angular $http.get()
calling to a another origin -
$http.get('http://itunes.apple.com/search', {
term: 'johnson'
});
but still this calling is denied by the browser and return error -
XMLHttpRequest cannot load https://itunes.apple.com/search. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
How could I make Cross Origin $http.get
calling from the index.html
correctly ?