mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Next js logging
This commit is contained in:
parent
0e643f59c0
commit
355c0e353e
1 changed files with 9 additions and 21 deletions
16
server.js
16
server.js
|
@ -67,20 +67,9 @@ app.use(cors())
|
|||
|
||||
app.use(function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
const isNextJs = Object.keys(modules).some((key) => {
|
||||
const x = modules[key]
|
||||
const match = x.urls.some((url) => {
|
||||
return url.includes(req.hostname)
|
||||
})
|
||||
if (match) {
|
||||
return x.isNextJs
|
||||
if (req.url.includes('_next/static')) {
|
||||
return
|
||||
}
|
||||
})
|
||||
if (isNextJs) {
|
||||
if (req.url === '/') {
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
}
|
||||
} else {
|
||||
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
let toLog = loggableKeywords.some((x) => {
|
||||
|
@ -88,7 +77,6 @@ app.use(function (req, res, next) {
|
|||
})
|
||||
if (toLog) { logger.LogReq(req) }
|
||||
if (res.statusCode !== 404) { logger.LogStat(req.url, ip) }
|
||||
}
|
||||
})
|
||||
next()
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue