1

I am working through a book on MEAN web development. It has several example apps. And at the beginning of each one it has me add the following code in the serve.js main app file that has all the routes and whatnot, but it never explains why. Can someone shed some light?

app.use(function (req, res, next) {
  res.setHeader('Access-Control-Allow-Origin', '*');
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
  res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, \Authorization');
  next();
});
Taylor Huston
  • 1,104
  • 3
  • 15
  • 31

0 Answers0