code: private String getBaseUri(HttpServletRequest req, CmsObject cms) {
  
          String baseUri = req.getParameter(PARAM_BASE_URI);
          if (CmsStringUtil.isEmptyOrWhitespaceOnly(baseUri)) {
              String referer = req.getHeader(HEADER_REFERER_KEY);
              CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot());
              if (site != null) {
                  String prefix = site.getServerPrefix(cms, "/") + OpenCms.getStaticExportManager().getVfsPrefix();
                  if ((referer != null) && referer.startsWith(prefix)) {
                      baseUri = referer.substring(prefix.length());
                  }
              }
          }
          return baseUri;
      }
docs: Returns the base URI.<p>
  
  @param req the servlet request
  @param cms the CmsObject
  
  @return the base URI