this my routes code
const Joi = require('joi')
const handler = require('../handler/get-request')
const route = {
method: 'POST',
path: '/IB',
options: {
tags: ['api', 'IB', 'request'],
description: 'Request New User IB',
notes: 'It will return new user IB data',
validate: {
payload: {
data: Joi.object().keys({
cifNo: Joi.string().min(5).max(45).required(),
userId: Joi.string().min(5).max(45).required(),
deviceInfo: Joi.string().min(3).max(45).required()
})
}
},
plugins: {
'hapi-swagger': {
responses: {
'200': {
description: 'Success'
}
}
}
},
auth: 'ib'
},
handler
}
module.exports = route
and this is my code where i registered the plugin hapi-auth-jwt
await server.register(require('hapi-auth-jwt2'))
server.auth.strategy('ib', 'jwt', {
key: config.internalServiceAccessToken,
validate: async function (decoded, request) {
// See https://github.com/dwyl/hapi-auth-jwt2
// provides checking for invalidated token after user logout
request.auth.decoded = decoded
const user = await request.server.methods.services.ib.auth.findUser(decoded.username)
return { isValid: user, credentials: decoded }
},
verifyOptions: { algorithms: ['RS256'] }
})
when i hit my routes, i got this error message, "Error: Missing Authentication".
Can someone explain me why? and help me to fix this error. Big Thanks!