public static URI buildRequestUri(final ServerWebExchange exchange, final String domain) {
        String path = domain;
        final String rewriteUri = exchange.getAttribute(Constants.REWRITE_URI);
        if (StringUtils.isNoneBlank(rewriteUri)) {
            path = path + rewriteUri;
        } else {
            ShenyuContext shenyuContext = exchange.getAttribute(Constants.CONTEXT);
            Objects.requireNonNull(shenyuContext);
            String realUrl = shenyuContext.getRealUrl();
            if (StringUtils.isNoneBlank(realUrl)) {
                path = path + realUrl;
            }
        }
        URI uri = exchange.getRequest().getURI();
        if (StringUtils.isNotEmpty(uri.getRawQuery()) && uri.getRawQuery().contains("%")
                || StringUtils.isNotEmpty(uri.getRawPath()) && uri.getRawPath().contains("%")) {
            path = path + "?" + RequestQueryCodecUtil.getCodecQuery(exchange);
            return UriComponentsBuilder.fromUriString(path).build(true).toUri();
        } else {
            if (StringUtils.isNotEmpty(uri.getQuery())) {
                path = path + "?" + uri.getQuery();
            }
            Objects.requireNonNull(path);
            return UriComponentsBuilder.fromUriString(path).build(false).toUri();
        }
    }
Build the final request uri.

@param exchange the exchange
@param domain   the domain
@return request uri
shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/RequestUrlUtils.java