HessTina-YuI commented on code in PR #3663:
URL: https://github.com/apache/incubator-shenyu/pull/3663#discussion_r913362468
##########
shenyu-web/src/main/java/org/apache/shenyu/web/filter/CrossFilter.java:
##########
@@ -58,15 +60,14 @@ public Mono<Void> filter(@NonNull final ServerWebExchange
exchange, @NonNull fin
if (CorsUtils.isCorsRequest(request)) {
ServerHttpResponse response = exchange.getResponse();
HttpHeaders headers = response.getHeaders();
- // "Access-Control-Allow-Origin"
+ // finger allow origins
final String origin = request.getHeaders().getOrigin();
- if (this.filterConfig.isAllowedAnyOrigin()) {
- headers.set(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origin);
- } else if (Objects.nonNull(this.filterConfig.getAllowedOrigin())
- &&
CollectionUtils.isNotEmpty(this.filterConfig.getAllowedOrigin().getPrefixes()))
{
+ boolean allowCors = this.filterConfig.isAllowedAnyOrigin();
+ if (!allowCors &&
Objects.nonNull(this.filterConfig.getAllowedOrigin())) {
final String scheme =
exchange.getRequest().getURI().getScheme();
final CrossFilterConfig.AllowedOriginConfig
allowedOriginConfig = this.filterConfig.getAllowedOrigin();
- Set<String> allowedOrigin = allowedOriginConfig.getPrefixes()
+ Set<String> allowedOrigin = new HashSet<>();
Review Comment:
Set<String> allowedOrigin =
Optional.ofNullable(allowedOriginConfig.getPrefixes()).orElse(Collections.emptySet())...
I think this will be abit moe concise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]