Advertisement
Guest User

Untitled

a guest
Nov 16th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. var express= require('express');
  2.  
  3. var app = express();
  4. app.use(allowCrossDomain);
  5.  
  6. app.options( function(){
  7. conosle.log('wwfwfwfw');
  8. })
  9.  
  10. app.all( function(){
  11. console.log('asdfasdfasf');
  12. })
  13.  
  14. app.use( function(req,res,next){
  15.  
  16. console.log('wtf');
  17.  
  18. });
  19.  
  20.  
  21.  
  22. app.listen(8080);
  23.  
  24. function allowCrossDomain(req, res, next) {
  25. res.header('Access-Control-Allow-Origin', '*');
  26. res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
  27. res.header('Access-Control-Allow-Headers', 'Content-Type');
  28. console.log('okkkkk');
  29. // intercept OPTIONS method
  30. if ('OPTIONS' == req.method) {
  31. res.send(200);
  32. }
  33. else {
  34. next();
  35. }
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement