|
@@ -1,46 +1,46 @@
|
|
|
-package com.xyzc.common.web.security.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;
|
|
|
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
-
|
|
|
-/**
|
|
|
- * 跨域配置
|
|
|
- *
|
|
|
- * @author 杨兴卓
|
|
|
- */
|
|
|
-@Configuration
|
|
|
-public class CorsConfig implements WebMvcConfigurer {
|
|
|
-
|
|
|
- @Bean
|
|
|
- public CorsFilter corsFilter() {
|
|
|
- final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
- final CorsConfiguration corsConfiguration = new CorsConfiguration();
|
|
|
- corsConfiguration.setAllowCredentials(true);
|
|
|
- corsConfiguration.addAllowedHeader("*");
|
|
|
- corsConfiguration.addAllowedOriginPattern("*");
|
|
|
- corsConfiguration.addAllowedMethod("*");
|
|
|
- source.registerCorsConfiguration("/**", corsConfiguration);
|
|
|
- return new CorsFilter(source);
|
|
|
- }
|
|
|
-
|
|
|
- @Bean
|
|
|
- public WebMvcConfigurer corsConfigurer() {
|
|
|
- return new WebMvcConfigurer() {
|
|
|
- @Override
|
|
|
- public void addCorsMappings(CorsRegistry registry) {
|
|
|
- registry.addMapping("/**")
|
|
|
- .allowedOrigins("*")
|
|
|
- .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
|
|
- .allowedHeaders("*")
|
|
|
- .allowCredentials(true);
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+//package com.xyzc.common.web.security.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;
|
|
|
+//import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
+//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * 跨域配置
|
|
|
+// *
|
|
|
+// * @author 杨兴卓
|
|
|
+// */
|
|
|
+//@Configuration
|
|
|
+//public class CorsConfig implements WebMvcConfigurer {
|
|
|
+//
|
|
|
+// @Bean
|
|
|
+// public CorsFilter corsFilter() {
|
|
|
+// final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
+// final CorsConfiguration corsConfiguration = new CorsConfiguration();
|
|
|
+// corsConfiguration.setAllowCredentials(true);
|
|
|
+// corsConfiguration.addAllowedHeader("*");
|
|
|
+// corsConfiguration.addAllowedOriginPattern("*");
|
|
|
+// corsConfiguration.addAllowedMethod("*");
|
|
|
+// source.registerCorsConfiguration("/**", corsConfiguration);
|
|
|
+// return new CorsFilter(source);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Bean
|
|
|
+// public WebMvcConfigurer corsConfigurer() {
|
|
|
+// return new WebMvcConfigurer() {
|
|
|
+// @Override
|
|
|
+// public void addCorsMappings(CorsRegistry registry) {
|
|
|
+// registry.addMapping("/**")
|
|
|
+// .allowedOrigins("*")
|
|
|
+// .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
|
|
+// .allowedHeaders("*")
|
|
|
+// .allowCredentials(true);
|
|
|
+// }
|
|
|
+// };
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|