Skip to content

Commit

Permalink
skip overwhelming morgan log
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtsam committed Dec 3, 2024
1 parent 28d5558 commit ece6756
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ app.use(compression())
// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
app.disable('x-powered-by')

app.use(morgan('tiny'))
app.use(
morgan('tiny', {
skip:
MODE === 'development'
? (req, res) => {
if (
req.url.startsWith('/node_modules') ||
req.url.startsWith('/app') ||
req.url.startsWith('/@') ||
req.url.startsWith('/__')
) {
if (res.statusCode === 200 || res.statusCode === 304) {
return true
}
}
}
: undefined,
}),
)

app.use((_, res, next) => {
res.locals.cspNonce = crypto.randomBytes(16).toString('hex')
Expand Down

0 comments on commit ece6756

Please sign in to comment.