forked from wangdahoo/script-error
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (19 loc) · 655 Bytes
/
server.js
File metadata and controls
25 lines (19 loc) · 655 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
const express = require('express')
const moment = require('moment')
let app = express()
let cdn = 'http://127.0.0.1:8080/'
let crossorigin = process.env.CROSSORIGIN
? 'anonymous'
: ''
app.use(express.static('public'))
app.engine('html', require('ejs').renderFile)
app.get('/err_report', (req, res) => {
let query = req.query
let timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
console.log(`[${timestamp}]\tERR_MSG=${query.err_msg}\tERR_LINE=${query.err_line}\tERR_URL=${query.err_url}`)
res.send('ok')
})
app.get('/*', (req, res) => {
res.render('index.html', { message: 'The Script Error', cdn, crossorigin })
})
app.listen(3000)