i'm new to nodejs and i'm making an api with hapijs to handle some functionalities from mi site, i want to be able to make a base url like api/* and make all others url that start with api/ pass throug some validations but only do that once, this is what i have so far:
server.route([
{
method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
path: "/api/*",
handler: function(request, reply){
is_authorized = auth(request.raw.req.headers['Authorization']);
if(!is_authorized){
reply(response.generate_json(null, 'no autorizado', 'UNAUTHORIZED')).code(401);
}
}
}
]);
but it doesn't work, when i call any other url like api/sockets/whatever it just passes even if it's not authorized.... is there any way i can achive this in hapijs??
via fr3d0
No comments:
Post a Comment