|
|
@ -1,10 +1,14 @@
|
|
|
|
package com.ruoyi.gateway.config;
|
|
|
|
package com.ruoyi.gateway.config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.gateway.handler.SentinelFallbackHandler;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import com.ruoyi.gateway.handler.SentinelFallbackHandler;
|
|
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
|
|
|
|
|
|
import org.springframework.web.cors.reactive.CorsWebFilter;
|
|
|
|
|
|
|
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
|
|
|
|
|
|
|
import org.springframework.web.util.pattern.PathPatternParser;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 网关限流配置
|
|
|
|
* 网关限流配置
|
|
|
@ -20,4 +24,18 @@ public class GatewayConfig
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new SentinelFallbackHandler();
|
|
|
|
return new SentinelFallbackHandler();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
public CorsWebFilter corsFilter() {
|
|
|
|
|
|
|
|
CorsConfiguration config = new CorsConfiguration();
|
|
|
|
|
|
|
|
config.addAllowedMethod("*");
|
|
|
|
|
|
|
|
config.addAllowedOrigin("*");
|
|
|
|
|
|
|
|
config.addAllowedHeader("*");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
|
|
|
|
|
|
|
source.registerCorsConfiguration("/**", config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new CorsWebFilter(source);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|