Professional Documents
Culture Documents
Exercise 23 - Cross-Origin Resource Sharing
Exercise 23 - Cross-Origin Resource Sharing
In the routes folder, add a new file named cors.js and add the following code to it:
var corsOptions;
console.log(req.header('Origin'));
else {
callback(null, corsOptions);
};
exports.cors = cors();
exports.corsWithOptions = cors(corsOptionsDelegate);
1
Then, open dishRouter.js and update it as follows:
...
...
dishRouter.route('/')
...
...
...
...
dishRouter.route('/:dishId')
2
...
...
...
...
dishRouter.route('/:dishId/comments')
...
...
...
3
...
dishRouter.route('/:dishId/comments/:commentId')
...
...
...
...