Guest User

Untitled

a guest
Mar 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. var express = require('express');
  2. var app = express();
  3. var allowCrossDomain = function(req, res, next) {
  4. res.header('Access-Control-Allow-Origin', '*');
  5. res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
  6. res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
  7.  
  8. // intercept OPTIONS method
  9. if ('OPTIONS' == req.method) {
  10. res.send(200);
  11. }
  12. else {
  13. next();
  14. }
  15. };
  16. app.use(allowCrossDomain);
Add Comment
Please, Sign In to add comment