TYPO3 add https or http for base url based on url

In Typoscript constant while defining the base url, we can check, if the site url is http or https. So if the site url is https, we can set the https for the baseurl

To do so, the typoscript is

 const.baseURL = h t t p://

[globalString =]  
 const.baseURL = h t t p://

[globalString =] AND [globalString =_SERVER|HTTPS=on]
 const.baseURL =