|
@@ -0,0 +1,26 @@
|
|
|
+package com.nokia.financeapi.config.web;
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 跨域配置
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+public class CorsConfig {
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public CorsFilter corsFilter() {
|
|
|
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
+ CorsConfiguration config = new CorsConfiguration();
|
|
|
+ config.setAllowCredentials(true);
|
|
|
+ config.addAllowedOriginPattern("*");
|
|
|
+ config.addAllowedHeader("*");
|
|
|
+ config.addAllowedMethod("*");
|
|
|
+ source.registerCorsConfiguration("/**", config);
|
|
|
+ return new CorsFilter(source);
|
|
|
+ }
|
|
|
+}
|