使用express-jwt模块时报错:algorithms is not defined

导致报错的语句(node_modules\_express-jwt@6.0.0@express-jwt\lib\index.js:22

if (!options.algorithms) throw new Error('algorithms should be set')

原因是:

2020.7.7日jwt更新之后,安装的express-jwt模块会默认为6.0.0版本,更新后的jwt需要在配置中加入algorithms属性,即设置jwt的算法。一般HS256为配置algorithms的默认值:

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐