如何将参数传递给graphqlHTTP中间件
我正试图将授权标头令牌有效负载从另一个上层中间件传递给graphqlHTTP中间件
app.use('/private',(req:Request,res:Response,next:Function) => {
if(!req.header('Authorization')){
res.json({
error:true,message:'Authorization bearer required'
})
}else{
const token = Buffer.from(req.header('Authorization').split('Bearer ')[1],'base64').toString('ascii');
if(decode(token)){
next();
}else{
res.json({
error:true,message:'Authorization bearer required'
})
}
}
});
app.use('/private',graphqlHTTP({
schema:privateSchema,graphiql:false
}))