123456789101112131415161718192021222324252627282930313233343536 |
- var path = require('path');
- var koa = require('koa');
- var bodyParser = require('koa-bodyparser');
- var cors = require('koa-cors');
- var serve = require('koa-static');
- var url = require('url');
- var allowedDomains = [
- 'brickup.io',
- 'localhost:3001'
- ];
- var app = koa();
- app.use(cors({ origin: function(req) {
- if (!req.header.referer)
- return 'http://brickup.io';
- var info = url.parse(req.header.referer);
- var index = allowedDomains.indexOf(info.host);
- if (index > -1) {
- return info.protocol + '//' + info.host;
- }
- return 'http://brickup.io';
- }}));
- app.use(serve(__dirname + '/public'));
- app.use(bodyParser());
- app.use(require('./apis/builder').routes());
- app.listen(3050, function() {
- console.log('Server is runnning at 3035 port');
- });
|