Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express= require('express');
- var app = express();
- app.use(allowCrossDomain);
- app.options( function(){
- conosle.log('wwfwfwfw');
- })
- app.all( function(){
- console.log('asdfasdfasf');
- })
- app.use( function(req,res,next){
- console.log('wtf');
- });
- app.listen(8080);
- function allowCrossDomain(req, res, next) {
- res.header('Access-Control-Allow-Origin', '*');
- res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
- res.header('Access-Control-Allow-Headers', 'Content-Type');
- console.log('okkkkk');
- // intercept OPTIONS method
- if ('OPTIONS' == req.method) {
- res.send(200);
- }
- else {
- next();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement