【发布时间】:2017-07-05 00:52:29
【问题描述】:
const URL = require('url').URL;
const myURL = new URL('https://example.org/foo');
console.log(myURL.href); // https://example.org/foo
console.log(myURL.protocol); // https:
console.log(myURL.hostname); // example.org
console.log(myURL.pathname); // /foo
但是如何获取用户向服务器发出的请求 url ???
【问题讨论】:
-
你能做req.header吗
-
它显示了标题中的所有内容。
-
其实是request.protocol,就是我要找的。不过谢谢你的关心,我很感激。
-
Node 是为 http 开发的...所以您的节点应用程序处理的请求无论如何都是 http(或 https)...
标签: node.js