first commit
This commit is contained in:
commit
3c0479faf0
169 files changed
+27617
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import type { HttpContext } from '@adonisjs/core/http'
|
||||
import type { NextFn } from '@adonisjs/core/types/http'
|
||||
|
||||
/**
|
||||
* The API always answers in JSON, including the errors raised before the
|
||||
* route middleware (CSRF) and the EventSource requests: an unauthenticated
|
||||
* stream gets a 401 instead of a redirect.
|
||||
*/
|
||||
export default class ForceJsonResponseMiddleware {
|
||||
handle(ctx: HttpContext, next: NextFn) {
|
||||
if (ctx.request.url().startsWith('/api/')) {
|
||||
ctx.request.request.headers.accept = 'application/json'
|
||||
}
|
||||
return next()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user