Javascript/Node.js Get Base Url From Url

November 1, 2020
// const url = new URL(req.headers.referer)
const url = new URL('https://code.luasoftware.com/tutorials/flask/generate-static-html-with-flask-frozen/')
const baseUrl = `${url.protocol}//${url.host}` // https://code.luasoftware.com

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.