fix(kernel): add cors as server middleware
This commit is contained in:
parent
f21bb01a6b
commit
22f43b4012
|
@ -13,7 +13,6 @@ const Server = use('Server')
|
||||||
*/
|
*/
|
||||||
const globalMiddleware = [
|
const globalMiddleware = [
|
||||||
'Adonis/Middleware/BodyParser',
|
'Adonis/Middleware/BodyParser',
|
||||||
'Adonis/Middleware/Cors',
|
|
||||||
'Adonis/Middleware/Session',
|
'Adonis/Middleware/Session',
|
||||||
'Adonis/Middleware/Shield',
|
'Adonis/Middleware/Shield',
|
||||||
'Adonis/Middleware/AuthInit'
|
'Adonis/Middleware/AuthInit'
|
||||||
|
@ -40,7 +39,22 @@ const namedMiddleware = {
|
||||||
auth: 'Adonis/Middleware/Auth'
|
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
|
Server
|
||||||
.registerGlobal(globalMiddleware)
|
.registerGlobal(globalMiddleware)
|
||||||
.registerNamed(namedMiddleware)
|
.registerNamed(namedMiddleware)
|
||||||
.use(['Adonis/Middleware/Static'])
|
.use(serverMiddleware)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user