Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Express based log server for Qici Engine
// hacked from the code at
var port = 8900;
var bodyParser = require('body-parser')
var express = require('express');
var app = express();
var http = require('http').Server(app);
// 监听端口重复事件以进行重试
http.on('error', function(e) {
console.error('端口监听失败:%s', e.code);
// Add headers
app.use(function(req, res, next) {
// Website you wish to allow to connect
// * wildcard, do not use :P
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
router = express.Router();
app.use('/remoteLog', router);
// 客户端请求 post'/', function(req, res) {
var body = req.body;
res.send("200 OK");
http.listen(port, function() {
console.log('成功监听端口:%d', port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.