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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -