Catch authentication error

This commit is contained in:
Hongbo Wu 2022-08-18 19:19:59 +08:00
parent 576318fcbe
commit a1171c7952

View file

@ -22,8 +22,13 @@ export function speechServiceRouter() {
body: req.body,
})
const token = req.query.token as string
if (!(await getClaimsByToken(token))) {
logger.info('Unauthorized request', { token })
try {
if (!(await getClaimsByToken(token))) {
logger.info('Unauthorized request', { token })
return res.status(200).send('UNAUTHORIZED')
}
} catch (error) {
logger.error('Unauthorized request', { token, error })
return res.status(200).send('UNAUTHORIZED')
}