volta il y a 2 ans
Parent
commit
4fcc239dd4

+ 3 - 3
launch-admin/src/main/java/com/webflux/launchadmin/config/LoginWebFiter.java

@@ -53,15 +53,15 @@ public class LoginWebFiter implements WebFilter {
         ServerHttpResponse response = exchange.getResponse();
         RequestPath path = request.getPath();
         //.跨域
-//        if (CorsUtils.isCorsRequest(request)) {
+        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");
-//        }
+            headers.add("Access-Control-Allow-Credentials", "true");
+        }
         //预检请求
         if (request.getMethod().equals(HttpMethod.OPTIONS.name())) {
             response.setStatusCode(HttpStatus.OK);

+ 0 - 25
launch-admin/src/main/java/com/webflux/launchadmin/config/MyWebConfiguration.java

@@ -1,25 +0,0 @@
-package com.webflux.launchadmin.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.config.CorsRegistry;
-import org.springframework.web.reactive.config.WebFluxConfigurer;
-
-@Configuration
-public class MyWebConfiguration {
-
-    //配置底层
-    @Bean
-    public WebFluxConfigurer webFluxConfigurer(){
-
-        return new WebFluxConfigurer() {
-            @Override
-            public void addCorsMappings(CorsRegistry registry) {
-                registry.addMapping("/**")
-                        .allowedHeaders("*")
-                        .allowedMethods("*")
-                        .allowedOrigins("localhost");
-            }
-        };
-    }
-}