diff --git a/start/kernel.js b/start/kernel.js index 0149871..72d769e 100644 --- a/start/kernel.js +++ b/start/kernel.js @@ -13,7 +13,6 @@ const Server = use('Server') */ const globalMiddleware = [ 'Adonis/Middleware/BodyParser', - 'Adonis/Middleware/Cors', 'Adonis/Middleware/Session', 'Adonis/Middleware/Shield', 'Adonis/Middleware/AuthInit' @@ -40,7 +39,22 @@ const namedMiddleware = { auth: 'Adonis/Middleware/Auth' } +/* +|-------------------------------------------------------------------------- +| Server Middleware +|-------------------------------------------------------------------------- +| +| Server levl middleware are executed even when route for a given URL is +| not registered. Features like `static assets` and `cors` needs better +| control over request lifecycle. +| +*/ +const serverMiddleware = [ + 'Adonis/Middleware/Static', + 'Adonis/Middleware/Cors' +] + Server .registerGlobal(globalMiddleware) .registerNamed(namedMiddleware) - .use(['Adonis/Middleware/Static']) + .use(serverMiddleware)