Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var express = require('express')
  2. , cors = require('cors')
  3. , app = express();
  4.  
  5. var corsOptions = {
  6. origin: 'http://example.com',
  7. optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
  8. };
  9.  
  10. app.get('/products/:id', cors(corsOptions), function(req, res, next){
  11. res.json({msg: 'This is CORS-enabled for only example.com.'});
  12. });
  13.  
  14. app.listen(80, function(){
  15. console.log('CORS-enabled web server listening on port 80');
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement