forked from Himmas/vue-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (30 loc) · 1.01 KB
/
app.js
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 kylin on 16/7/15.
*/
var express = require('express')
var app = express()
var bodyParser = require('body-parser')
var hostSetting = require('./hostSetting')
var routes = require('./route/index')
app.use('/static', express.static('./static'))
// app.use(bodyParser())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }))
//设置跨域访问
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*")
// res.header("Access-Control-Allow-Headers", "X-Requested-With")
res.header('Access-Control-Allow-Headers', 'X-Requested-With,Content-Type')
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS")
res.header("X-Powered-By",' 3.2.1')
res.header("Content-Type", "application/json;charset=utf-8")
next();
});
routes(app)
module.exports = app.listen(hostSetting.port, function (err) {
if (err) {
console.log(err)
return
}
console.log('Listening at http://localhost:'+hostSetting.port)
})