From 8195e948a16acf33cb8101ef74f2299e50580ff4 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 24 六月 2021 09:34:06 +0800
Subject: [PATCH] 发布 v2.4.0
---
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
index f10ea2d..c3cdc94 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
@@ -1,7 +1,11 @@
package com.ruoyi.framework.config;
import org.springframework.beans.factory.annotation.Autowired;
+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.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -11,7 +15,7 @@
/**
* 閫氱敤閰嶇疆
- *
+ *
* @author ruoyi
*/
@Configuration
@@ -25,10 +29,6 @@
{
/** 鏈湴鏂囦欢涓婁紶璺緞 */
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
-
- /** swagger閰嶇疆 */
- registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
/**
@@ -39,4 +39,24 @@
{
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
}
-}
\ No newline at end of file
+
+ /**
+ * 璺ㄥ煙閰嶇疆
+ */
+ @Bean
+ public CorsFilter corsFilter()
+ {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ // 璁剧疆璁块棶婧愬湴鍧�
+ config.addAllowedOriginPattern("*");
+ // 璁剧疆璁块棶婧愯姹傚ご
+ config.addAllowedHeader("*");
+ // 璁剧疆璁块棶婧愯姹傛柟娉�
+ config.addAllowedMethod("*");
+ // 瀵规帴鍙i厤缃法鍩熻缃�
+ source.registerCorsConfiguration("/**", config);
+ return new CorsFilter(source);
+ }
+}
--
Gitblit v1.9.3