护照-jwt总是返回未经授权的401

imToken 是一款全球领先的区块链数字资产管理工具[ZB],帮助你安全管理BTC, ETH, ATOM, EOS, TRX, CKB, BCH, LTC, DOT, KSM, FIL, XTZ 资产,同时支持去中心化币币兑换功能 ...

为了解决这个问题,您可以在中间件中进行管理 (, , next) { .('jwt', { : false, }, async (error, token) => { if (error || !token) { .(401).json({ : ' ' }); } try { .log('token',token) const user = await User.( {_id: token._id} ); .user = user; } catch (error) { next(error); } next(); })(, , next); }.get( '/', , .all, user.)

middleware jwt authentication function

passport authenticate token middleware

trim request all middleware

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

返回顶部
跳到底部

Copyright © 2002-2024 imToken钱包下载官网 Rights Reserved.
备案号:晋ICP备13003952号

谷歌地图 | 百度地图
Powered by Z-BlogPHP Theme By open开发