|
|
@@ -3,6 +3,7 @@ package com.ruoyi.file.config;
|
|
3
|
3
|
import java.io.File;
|
|
4
|
4
|
import org.springframework.beans.factory.annotation.Value;
|
|
5
|
5
|
import org.springframework.context.annotation.Configuration;
|
|
|
6
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
6
|
7
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
7
|
8
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
8
|
9
|
|
|
|
@@ -33,4 +34,17 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|
33
|
34
|
registry.addResourceHandler(localFilePrefix + "/**")
|
|
34
|
35
|
.addResourceLocations("file:" + localFilePath + File.separator);
|
|
35
|
36
|
}
|
|
|
37
|
+
|
|
|
38
|
+ /**
|
|
|
39
|
+ * 开启跨域
|
|
|
40
|
+ */
|
|
|
41
|
+ @Override
|
|
|
42
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
43
|
+ // 设置允许跨域的路由
|
|
|
44
|
+ registry.addMapping(localFilePrefix + "/**")
|
|
|
45
|
+ // 设置允许跨域请求的域名
|
|
|
46
|
+ .allowedOrigins("*")
|
|
|
47
|
+ // 设置允许的方法
|
|
|
48
|
+ .allowedMethods("GET");
|
|
|
49
|
+ }
|
|
36
|
50
|
}
|