-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (25 loc) · 802 Bytes
/
Copy pathserver.js
File metadata and controls
36 lines (25 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Created by Nonjene on 2017/3/6.
*/
const serve = require('koa-static');
const Koa = require('koa');
const server = new Koa();
const conditional = require('koa-conditional-get');
const proxy = require('koa-proxy');
const program = require("commander");
let proxyPort = '80',
servePort = '3005';
program
.option('S, --serve-port <port>', '端口', port => servePort = port)
.option('P, --proxy-port <port>', '端口', port => proxyPort = port)
.parse(process.argv);
server.use(proxy({
host: 'http://localhost:' + proxyPort, //代理地址
match: /^\/(?!activity\/)/ // 非活动页面
}));
server.use(conditional());
server.use(serve(process.cwd() + '/build/', {
maxage: 31536000000
}));
server.listen(servePort);
console.log('server started.');