使用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的默认值:

在更新到express-jwt 6.0.0版本后,遇到'algorithm is not defined'的错误。原因是新版本要求在配置中指定jwt算法。解决方案是在配置中添加'algorithms'属性,通常设置为'HS256'作为默认值。
905

被折叠的 条评论
为什么被折叠?



