mirror of
https://github.com/typicode/json-server.git
synced 2025-07-29 21:23:41 +08:00
moving logger after express.static to prevent unnecessary logging of static files with express (#587)
This commit is contained in:
@ -22,16 +22,6 @@ module.exports = function(opts) {
|
||||
arr.push(compression())
|
||||
}
|
||||
|
||||
// Logger
|
||||
if (opts.logger) {
|
||||
arr.push(
|
||||
logger('dev', {
|
||||
skip: req =>
|
||||
process.env.NODE_ENV === 'test' || req.path === '/favicon.ico'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// Enable CORS for all the requests, including static files
|
||||
if (!opts.noCors) {
|
||||
arr.push(cors({ origin: true, credentials: true }))
|
||||
@ -45,6 +35,16 @@ module.exports = function(opts) {
|
||||
// Serve static files
|
||||
arr.push(express.static(opts.static))
|
||||
|
||||
// Logger
|
||||
if (opts.logger) {
|
||||
arr.push(
|
||||
logger('dev', {
|
||||
skip: req =>
|
||||
process.env.NODE_ENV === 'test' || req.path === '/favicon.ico'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// No cache for IE
|
||||
// https://support.microsoft.com/en-us/kb/234067
|
||||
arr.push((req, res, next) => {
|
||||
|
Reference in New Issue
Block a user