Docs

URL.prototype.host

The host (hostname and port) of the URL.

Example

let url = new URL("https://example.com:8080/path")
url.host
"example.com:8080"
let url = new URL("https://example.com/path")
url.host
"example.com"