|
@@ -1,28 +1,28 @@
|
1
|
|
-package com.yunzhi.marketing.config;
|
2
|
|
-
|
3
|
|
-import org.springframework.context.annotation.Bean;
|
4
|
|
-import org.springframework.context.annotation.Configuration;
|
5
|
|
-import org.springframework.web.cors.CorsConfiguration;
|
6
|
|
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
7
|
|
-import org.springframework.web.filter.CorsFilter;
|
8
|
|
-
|
9
|
|
-/**
|
10
|
|
- * 解决跨域问题
|
11
|
|
- */
|
12
|
|
-@Configuration
|
13
|
|
-public class CorsConfig {
|
14
|
|
- private CorsConfiguration buildConfig() {
|
15
|
|
- CorsConfiguration corsConfiguration = new CorsConfiguration();
|
16
|
|
- corsConfiguration.addAllowedOrigin("*"); // 1 允许任何域名使用
|
17
|
|
- corsConfiguration.addAllowedHeader("*"); // 2 允许任何头
|
18
|
|
- corsConfiguration.addAllowedMethod("*"); // 3 允许任何方法(post、get等)
|
19
|
|
- return corsConfiguration;
|
20
|
|
- }
|
21
|
|
-
|
22
|
|
- @Bean
|
23
|
|
- public CorsFilter corsFilter() {
|
24
|
|
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
25
|
|
- source.registerCorsConfiguration("/**", buildConfig()); // 4
|
26
|
|
- return new CorsFilter(source);
|
27
|
|
- }
|
28
|
|
-}
|
|
1
|
+//package com.yunzhi.marketing.config;
|
|
2
|
+//
|
|
3
|
+//import org.springframework.context.annotation.Bean;
|
|
4
|
+//import org.springframework.context.annotation.Configuration;
|
|
5
|
+//import org.springframework.web.cors.CorsConfiguration;
|
|
6
|
+//import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
7
|
+//import org.springframework.web.filter.CorsFilter;
|
|
8
|
+//
|
|
9
|
+///**
|
|
10
|
+// * 解决跨域问题
|
|
11
|
+// */
|
|
12
|
+//@Configuration
|
|
13
|
+//public class CorsConfig {
|
|
14
|
+// private CorsConfiguration buildConfig() {
|
|
15
|
+// CorsConfiguration corsConfiguration = new CorsConfiguration();
|
|
16
|
+// corsConfiguration.addAllowedOrigin("*"); // 1 允许任何域名使用
|
|
17
|
+// corsConfiguration.addAllowedHeader("*"); // 2 允许任何头
|
|
18
|
+// corsConfiguration.addAllowedMethod("*"); // 3 允许任何方法(post、get等)
|
|
19
|
+// return corsConfiguration;
|
|
20
|
+// }
|
|
21
|
+//
|
|
22
|
+// @Bean
|
|
23
|
+// public CorsFilter corsFilter() {
|
|
24
|
+// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
25
|
+// source.registerCorsConfiguration("/**", buildConfig()); // 4
|
|
26
|
+// return new CorsFilter(source);
|
|
27
|
+// }
|
|
28
|
+//}
|