NodeJS中的window.locaton和window.pathname等效

NodeJS / ExpressJS中的window.location.protocolwindow.location.host等价于什么?

我正尝试使用第三方API将urlredirect到我的网站。

NodeJS API url.format(urlObject)方法返回从urlObject派生的格式化的URLstring。

 var url = require('url'); function getFormattedUrl(req) { return url.format({ protocol: req.protocol, host: req.get('host') }); } res.redirect(getFormattedUrl(req));