修复调用不存在的接口导致API崩溃的问题 #1345

This commit is contained in:
binaryify 2021-09-04 14:56:28 +08:00
parent 28289beb8d
commit 0e658f9b5a

8
app.js
View File

@ -117,6 +117,14 @@ fs.readdirSync(path.join(__dirname, 'module'))
status: answer.status,
body: answer.body,
})
if (!answer.body) {
res.status(404).send({
code: 404,
data: null,
msg: 'Not Found',
})
return
}
if (answer.body.code == '301') answer.body.msg = '需要登录'
res.append('Set-Cookie', answer.cookie)
res.status(answer.status).send(answer.body)