You can use Passportjs to protect your routes, passport will be your middleman between person accessing the back-end and your actual back-end.
(您可以使用Passportjs保护您的路线,护照是访问后端人员和实际后端之间的中间人。)
You can give access to the routes if a valid JWT is passed ( JWT strategy ) otherwise it will throw 401 (Unauthorized).
(如果传递了有效的JWT( JWT策略 ),则可以授予对路由的访问权限,否则它将抛出401(未经授权)。)
There are 400+ strategies available, I will recommend JWT one because you are already generating JWT.
(有400多种策略可用,我将推荐一种JWT,因为您已经在生成JWT。)
Protecting backed is integral part because most of scripts can disable security on front-end leaving apps vulnerable to attacks.
(保护受支持是不可或缺的一部分,因为大多数脚本可能会禁用前端的安全性,从而使应用程序容易受到攻击。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…