如何在 Hapi.Js 中获取完整的 url?
How to get the full url in Hapi.Js?
request.url
是 returns 路由的对象,但不是 node/hapi 框架中的完整 url。
如何获得完整的 url?
来自docs:
url - the parsed request URI.
因此,URL 对象实际上只是一个 URI(不包含协议信息和主机)。
对于完整的 URL,您需要按以下方式构建它:
var url = request.connection.info.protocol + '://' + request.info.host + request.url.path;
自己找到答案:
request.info.host
request.url
是 returns 路由的对象,但不是 node/hapi 框架中的完整 url。
如何获得完整的 url?
来自docs:
url - the parsed request URI.
因此,URL 对象实际上只是一个 URI(不包含协议信息和主机)。
对于完整的 URL,您需要按以下方式构建它:
var url = request.connection.info.protocol + '://' + request.info.host + request.url.path;
自己找到答案:
request.info.host