expressjs / morgan

HTTP request logger middleware for node.js
MIT License
7.95k stars 536 forks source link

how to capture post method #243

Closed handv closed 4 years ago

handv commented 4 years ago

when i send a post request, the morgan only capture the OPTIONS method request, how can i capture the POST method request and skip the OPTIONS one? thank u very much for answer my question

handv commented 4 years ago

when i send a post request, the morgan only capture the OPTIONS method request, how can i capture the POST method request and skip the OPTIONS one? thank u very much for answer my question

I have found the reason. In my server.js, i wrote this:

app.use(router.routes());
app.use(morgan('short'))

But change the order of the two lines code, i capture the POST request, like this:

app.use(morgan('short'))
app.use(router.routes());