Bugfix/Correctly throw 401 error when unauthorized (#2626)

correctly throw 401 error when unauthorized
This commit is contained in:
Henry Heng
2024-06-12 19:10:42 +01:00
committed by GitHub
parent 5ba468b4cc
commit 3ab0d99711
4 changed files with 28 additions and 10 deletions
+5 -1
View File
@@ -417,7 +417,11 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
return result
} catch (e) {
logger.error('[server]: Error:', e)
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, getErrorMessage(e))
if (e instanceof InternalFlowiseError && e.statusCode === StatusCodes.UNAUTHORIZED) {
throw e
} else {
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, getErrorMessage(e))
}
}
}