Parcourir la source

feat : 去掉代码里的跨域解决代码

bilingfeng il y a 2 ans
Parent
commit
cdb7af45eb

+ 0 - 1
game-module/game-manage/src/main/java/com/zanxiang/manage/ManageApplication.java

@@ -7,7 +7,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.web.bind.annotation.CrossOrigin;
 
-@CrossOrigin
 @Slf4j
 @EnableDiscoveryClient
 @SpringBootApplication

+ 31 - 31
game-module/game-manage/src/main/java/com/zanxiang/manage/config/CORSConfig.java

@@ -1,31 +1,31 @@
-package com.zanxiang.manage.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-/**
- * @author : lingfeng
- * @time : 2022-06-16
- * @description : 跨域配置
- */
-@Configuration
-public class CORSConfig {
-
-    private CorsConfiguration buildConfig() {
-        CorsConfiguration corsConfiguration = new CorsConfiguration();
-        corsConfiguration.addAllowedOrigin("*");
-        corsConfiguration.addAllowedHeader("*");
-        corsConfiguration.addAllowedMethod("*");
-        return corsConfiguration;
-    }
-
-    @Bean
-    public CorsFilter corsFilter() {
-        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-        source.registerCorsConfiguration("/**", buildConfig());
-        return new CorsFilter(source);
-    }
-}
+//package com.zanxiang.manage.config;
+//
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.web.cors.CorsConfiguration;
+//import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+//import org.springframework.web.filter.CorsFilter;
+//
+///**
+// * @author : lingfeng
+// * @time : 2022-06-16
+// * @description : 跨域配置
+// */
+//@Configuration
+//public class CORSConfig {
+//
+//    private CorsConfiguration buildConfig() {
+//        CorsConfiguration corsConfiguration = new CorsConfiguration();
+//        corsConfiguration.addAllowedOrigin("*");
+//        corsConfiguration.addAllowedHeader("*");
+//        corsConfiguration.addAllowedMethod("*");
+//        return corsConfiguration;
+//    }
+//
+//    @Bean
+//    public CorsFilter corsFilter() {
+//        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+//        source.registerCorsConfiguration("/**", buildConfig());
+//        return new CorsFilter(source);
+//    }
+//}

+ 32 - 32
game-module/game-manage/src/main/java/com/zanxiang/manage/filter/CORSFilter.java

@@ -1,32 +1,32 @@
-package com.zanxiang.manage.filter;
-
-import org.springframework.context.annotation.Configuration;
-
-import javax.servlet.*;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author : lingfeng
- * @time : 2022-06-16
- * @description : 过滤器
- */
-@WebFilter(filterName = "CorsFilter ")
-@Configuration
-public class CORSFilter implements Filter {
-
-    @Override
-    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
-        HttpServletResponse response = (HttpServletResponse) res;
-        HttpServletRequest request = (HttpServletRequest) req;
-        response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
-        response.setHeader("Access-Control-Allow-Credentials", "true");
-        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT, OPTION");
-        response.setHeader("Access-Control-Max-Age", "3600");
-        response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, cookie, token, Authorization");
-        chain.doFilter(req, res);
-    }
-
-}
+//package com.zanxiang.manage.filter;
+//
+//import org.springframework.context.annotation.Configuration;
+//
+//import javax.servlet.*;
+//import javax.servlet.annotation.WebFilter;
+//import javax.servlet.http.HttpServletRequest;
+//import javax.servlet.http.HttpServletResponse;
+//import java.io.IOException;
+//
+///**
+// * @author : lingfeng
+// * @time : 2022-06-16
+// * @description : 过滤器
+// */
+//@WebFilter(filterName = "CorsFilter ")
+//@Configuration
+//public class CORSFilter implements Filter {
+//
+//    @Override
+//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
+//        HttpServletResponse response = (HttpServletResponse) res;
+//        HttpServletRequest request = (HttpServletRequest) req;
+//        response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
+//        response.setHeader("Access-Control-Allow-Credentials", "true");
+//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT, OPTION");
+//        response.setHeader("Access-Control-Max-Age", "3600");
+//        response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, cookie, token, Authorization");
+//        chain.doFilter(req, res);
+//    }
+//
+//}