Skip to content

Commit 68b3b0f

Browse files
jameelmosestypicode
authored andcommitted
moving logger after express.static to prevent unnecessary logging of static files with express (typicode#587)
1 parent c9bf6df commit 68b3b0f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/server/defaults.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ module.exports = function(opts) {
2222
arr.push(compression())
2323
}
2424

25-
// Logger
26-
if (opts.logger) {
27-
arr.push(
28-
logger('dev', {
29-
skip: req =>
30-
process.env.NODE_ENV === 'test' || req.path === '/favicon.ico'
31-
})
32-
)
33-
}
34-
3525
// Enable CORS for all the requests, including static files
3626
if (!opts.noCors) {
3727
arr.push(cors({ origin: true, credentials: true }))
@@ -45,6 +35,16 @@ module.exports = function(opts) {
4535
// Serve static files
4636
arr.push(express.static(opts.static))
4737

38+
// Logger
39+
if (opts.logger) {
40+
arr.push(
41+
logger('dev', {
42+
skip: req =>
43+
process.env.NODE_ENV === 'test' || req.path === '/favicon.ico'
44+
})
45+
)
46+
}
47+
4848
// No cache for IE
4949
// https://support.microsoft.com/en-us/kb/234067
5050
arr.push((req, res, next) => {

0 commit comments

Comments
 (0)