在 NodeJS 中,我如何在没有 HTTP 重定向的情况下将路由转发到另一个路由?
例如,我希望根请求('/'(从我的静态路由处理程序获取索引.html。所以/
会得到与/public/index.html
相同的回复.
据我所知,路由的处理程序函数中没有这样的功能。
快乐的方法是使用服务器扩展:
server.ext('onRequest', function (request, reply) {
if (request.path == '/')
request.setUrl('/public/index.html');
return reply.continue();
});