Midwayv3.6.0+的守卫功能,无法自定义返回的body的状态码,当前写死的500 #3900
Unanswered
ruiruiStudy
asked this question in
Q&A
Replies: 1 comment
-
源码里是兜底啊,你需要在守卫里返回自定义的错误。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the problem(描述问题)
比如,自定义一个全局路由守卫,希望无权限时返回的body = { code: 403, message: '没有权限' },但是源码里默认写死了500,源码返回的部分内容如下:
`
const isPassed = await this.app
.getFramework()
.runGuard(ctx, routeInfo.controllerClz, routeInfo.method);
if (!isPassed) {
throw new error_1.httpError.ForbiddenError();
}
`
Midway Versions(Midway 版本)
Need to install the following packages:
[email protected]
Ok to proceed? (y)
Beta Was this translation helpful? Give feedback.
All reactions