‘mage/url’ widget is not used to fetch backend base URL in Magento 2.
You need to create a template file using layout XML and define the base URL of backend under the template file. Continue reading “Get Backend Base Url in JS file Magento 2?”
You can get the base URL of the store in the controller file using Store Manager Interface.
To Retrieve the Base URL of the current store, You need to instantiate constructor in your controller file,
Check below code snippet for getting base URL, Continue reading “Get Base Url in Model or Plugin file Magento 2.”