var express = require(‘express’); var router = express.Router(); var Token = require(‘…/…/common/token’);
router.get('/’,function(req,res){
console.log(req.header('xsToken')+'!!!!!!!!!!!!!!!!!!!!!!!!!!!');
var token = req.header('xsToken');
var test = Token.decode(token);
//var test = Token.decode(
//"NTVCNzZCNUMyRTkwN0Y5RkNCRUUxOCIsImV4cGlyZXMiOjE0MzIyODQwOTQzMDd9.rl8sRx64eDQK7F_FHw7LJ7hO1mR1ZS17NLKwFhigOC4"
//);
res.send(test);
console.log(test+'!!!!!!!!!!!');
});
module.exports = router;
使用jwt-simple,程序如上所示,get请求,希望decode使用req.hearder(‘Token’)传来的字符串,打印req.hearder(‘Token’)是字符串,但是作为参数就会报如下错误。直接穿字符串又是正确的,求解是为什么??
GET /feeds 500 10.792 ms - 1187 Error: Signature verification failed at Object.jwt_decode [as decode] (/Users/qxue/xq/HeartVoice_Backend/node_modules/jwt-simple/lib/jwt.js:83:13) at Object.exports.decode (/Users/qxue/xq/HeartVoice_Backend/common/token.js:21:16) at /Users/qxue/xq/HeartVoice_Backend/router/routes/feed.js:15:22 at Layer.handle [as handle_request] (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/layer.js:82:5) at next (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/route.js:110:13) at Route.dispatch (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/route.js:91:3) at Layer.handle [as handle_request] (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/layer.js:82:5) at /Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/index.js:267:22 at Function.proto.process_params (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/index.js:321:12) at next (/Users/qxue/xq/HeartVoice_Backend/node_modules/express/lib/router/index.js:261:10)