mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	 5fc763775e
			
		
	
	
		5fc763775e
		
			
		
	
	
	
	
		
			
			In the examples and project templates the "errors" middleware which turn thrown errors into HTTP responses is registered before the "logger" middleware. This causes any errors thrown in controllers to pierce through the logger middleware resulting in these requests not being logged. Eg. when a controller throws a ValidationError the resulting HTTP 400 request is not logged at all. Change the order of middleware registration so that the logger is 'above' the errors middleware and has a chance to log *all* requests. Co-authored-by: DMehaffy <derrickmehaffy@gmail.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			596 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			596 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const responseHandlers = require('./src/response-handlers');
 | |
| 
 | |
| module.exports = [
 | |
|   'strapi::logger',
 | |
|   'strapi::errors',
 | |
|   'strapi::security',
 | |
|   'strapi::cors',
 | |
|   'strapi::poweredBy',
 | |
|   'strapi::query',
 | |
|   'strapi::body',
 | |
|   'strapi::session',
 | |
|   // 'strapi::compression',
 | |
|   // 'strapi::ip',
 | |
|   {
 | |
|     name: 'strapi::responses',
 | |
|     config: {
 | |
|       handlers: responseHandlers,
 | |
|     },
 | |
|   },
 | |
|   'strapi::favicon',
 | |
|   'strapi::public',
 | |
|   {
 | |
|     name: 'global::test-middleware',
 | |
|     config: {
 | |
|       foo: 'bar',
 | |
|     },
 | |
|   },
 | |
|   {
 | |
|     resolve: './src/custom/middleware.js',
 | |
|     config: {},
 | |
|   },
 | |
| ];
 |