node.js - not loading jquery files in nodejs with hapi -
i 've tried both code (commented , uncommented) in commented code shows error reply.file not fumction . in uncommented code shows error unknown handler file 've included inert.
server.route({ // other assets if have method: 'get', path: '/public/js/{filename}', handler: { file: function (request) { return './public/js/'+request.params.filename; } // try{ // console.log(request.params); // reply.file( './public/js/'+request.params.filename); // } // catch(e){ // console.log(e); // reply.file( './public/js/'+request.params.filename); // } } });
see: http://hapijs.com/tutorials/serving-files#relative-paths use inert module
server.register(inert, function () { server.route( { method: 'get', path: '/{param*}', handler: { directory: { path: path.normalize(__dirname + '/') } } });
you can try
server.register(inert, () =>{ server.route( { method: 'get', path: '/public/js/{filename}', handler: { file: function (request) { return __dirname+'/public/js/'+request.params.filename; } } }); });
Comments
Post a Comment