public static String getBaseUrl() {
        try {
            var requestAttrs = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
            return getBaseUrl(requestAttrs.getRequest());
        } catch (IllegalStateException e) {
            // method is called outside of web request context
            return "";
        }
    }
@Test
    public void testWithoutXForwarded() throws Exception {
        doReturn("http").when(request).getScheme();
        doReturn("localhost").when(request).getServerName();
        doReturn(8080).when(request).getServerPort();
        doReturn("/").when(request).getContextPath();
        assertThat(UrlUtil.getBaseUrl(request)).isEqualTo("http://localhost:8080/");
    }