app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://localhost:8081');
// allowed header type
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
res.header("Access-Control-Allow-Methods","DELETE,PUT,POST,GET,OPTIONS");
if (req.method.toLowerCase() == 'options')
res.send (200); // try to request a quick end to make options
else
next();
});