8
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

But how do I get it for request url that user made to the server???

Left Over
  • 241
  • 3
  • 16

1 Answers1

8

Simply by doing request.protocol like

    exports.nameOfFunction = function(request, response){
    var proto = request.protocol;
    console.log(proto);
}