标签:on() == require host node method false head lis
var express = require(‘express‘);
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: false }));
app.all(‘*‘,function(req,res,next){
    res.header(‘Access-Control-Allow-Origin‘,‘*‘);
    if(req.method==‘OPTIONS‘) res.send(200);
    else next();
})
app.get(‘/demo‘,function(req,res){
    res.send({
        a:1,
        b:2
    })
})
var server = app.listen(80,function(){
    var host= server.address().address;
    var port = server.address().port;
    console.log(‘访问地址:http//‘,host,port);
})
标签:on() == require host node method false head lis
原文地址:http://www.cnblogs.com/yiyi17/p/node.html