|
|
@@ -18,14 +18,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.buffer.DataBuffer;
|
|
|
import org.springframework.data.redis.core.ReactiveRedisTemplate;
|
|
|
-import org.springframework.http.HttpCookie;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.http.server.RequestPath;
|
|
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.cors.reactive.CorsUtils;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
import org.springframework.web.server.WebFilter;
|
|
|
import org.springframework.web.server.WebFilterChain;
|
|
|
@@ -51,7 +50,24 @@ public class LoginWebFiter implements WebFilter {
|
|
|
@Override
|
|
|
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
|
|
ServerHttpRequest request = exchange.getRequest();
|
|
|
+ ServerHttpResponse response = exchange.getResponse();
|
|
|
RequestPath path = request.getPath();
|
|
|
+ //.跨域
|
|
|
+ if (CorsUtils.isCorsRequest(request)) {
|
|
|
+ HttpHeaders headers = response.getHeaders();
|
|
|
+ //解决跨域的问题
|
|
|
+ headers.add("Access-Control-Allow-Origin", "*");
|
|
|
+ headers.add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
|
+ headers.add("Access-Control-Allow-Headers", "*");
|
|
|
+ headers.add("Access-Control-Max-Age", "3600");
|
|
|
+ headers.add("Access-Control-Allow-Credentials", "false");
|
|
|
+ }
|
|
|
+ //预检请求
|
|
|
+ if (request.getMethod().equals(HttpMethod.OPTIONS.name())) {
|
|
|
+ response.setStatusCode(HttpStatus.OK);
|
|
|
+ return response.setComplete();
|
|
|
+ }
|
|
|
+
|
|
|
String string = path.toString();
|
|
|
String[] split = xxlSsoExcludedPaths.split(",");
|
|
|
String[] split1 = xxlSsoExcludedstart.split(",");
|