I’m using below code to get base url in magento 2.
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
echo $baseurl = $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
Let me know how to get secure base url.
2
Answers
Your code is correct, just pass the second parameter boolean
true
withgetBaseUrl()
method, by default its null, use below code like :