header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Headers: content-type');
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "*");
response.setHeader("Access-Control-Allow-Headers", "content-type");
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'origin, content-type, accept');
app.use(function (req, res, next) {
var origins = [
'http://example.com',
'http://www.example.com'
];
for(var i = 0; i < origins.length; i++){
var origin = origins[i];
if(req.headers.origin.indexOf(origin) > -1){
res.header('Access-Control-Allow-Origin', req.headers.origin);
}
}
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});