hapijs - hapi catch all route without assets folder 404 status -
i'm working on spa , want manage 404 status without using separate folder (assets in case)
server.route( { // angular/api route method: 'get', path: '/api', handler: function (request, reply) { reply( {api: 'response' } ) } }); server.route({ // other assets if have method: 'get', path: '/assets/{param*}', handler: { directory: { path: './assets', listing: false, index: true } }); server.route({ // else method: 'get', path: '/{p*}', handler: function (request, reply) { reply.file('public/html/index.html'); } });
i mean i've got deploy like
so if use assets i've change deploy , gulpfile.
is there way manage 404 status without using folder ?
update worked out following tip of @matt harrison
server.ext('onpreresponse', function (request, reply) { var req = request.response; if (req.isboom && (req.output.statuscode===404)) { return reply.redirect('/#!/404'); } return reply.continue(); });
Comments
Post a Comment