Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express')
- , cors = require('cors')
- , app = express();
- var corsOptions = {
- origin: 'http://example.com',
- optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
- };
- app.get('/products/:id', cors(corsOptions), function(req, res, next){
- res.json({msg: 'This is CORS-enabled for only example.com.'});
- });
- app.listen(80, function(){
- console.log('CORS-enabled web server listening on port 80');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement