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://www.mysite.com/
[globalString = ENV:HTTP_HOST=www.mysite.com]
const.baseURL = h t t p://www.mysite.com/
[globalString = ENV:HTTP_HOST=www.mysite.com] AND [globalString =_SERVER|HTTPS=on]
const.baseURL =
[global]