|
@@ -22,8 +22,8 @@ import java.util.Set;
|
22
|
22
|
public class RestCorsFilter implements Filter {
|
23
|
23
|
|
24
|
24
|
//配置文件:application-cas-test.yml -> caseitc:
|
25
|
|
-// @Autowired
|
26
|
|
-// private CasConfig casConfig;
|
|
25
|
+ @Autowired
|
|
26
|
+ private CasConfig casConfig;
|
27
|
27
|
|
28
|
28
|
|
29
|
29
|
public RestCorsFilter() {
|
|
@@ -42,10 +42,10 @@ public class RestCorsFilter implements Filter {
|
42
|
42
|
log.info("【跨域过滤器】request.getRequestURL() = " + request.getRequestURL());//http://192.168.3.200:8180/system/role/41749924753409
|
43
|
43
|
// log.info("【跨域过滤器】request.getServletContext().getRealPath(\"/\") = " + request.getServletContext().getRealPath("/"));//获取“/”在机器中的实际地址 C:\Users\15753\AppData\Local\Temp\tomcat-docbase.8180.7251487789088039644\
|
44
|
44
|
|
45
|
|
-// String serverLoginUrl = casConfig.getServerLoginUrl();
|
46
|
|
-// String webStartPage = casConfig.getWebStartPage();
|
47
|
|
-// log.info("【跨域过滤器】serverLoginUrl = " + serverLoginUrl);
|
48
|
|
-// log.info("【跨域过滤器】webStartPage = " + webStartPage);
|
|
45
|
+ String serverLoginUrl = casConfig.getServerLoginUrl();//单点地址:http://10.152.70.21:8080/cas/login
|
|
46
|
+ String webStartPage = casConfig.getWebStartPage();//前端Ngxin地址:http://10.152.72.7:8181/postcheck
|
|
47
|
+ log.info("【跨域过滤器】设置动态从配置文件中取值-单点地址(注意:应该需要切割“/cas/login”,如果前端提示跨域需要处理一下端口的地址) = " + serverLoginUrl);
|
|
48
|
+ log.info("【跨域过滤器】设置动态从配置文件中取值-前端Ngxin地址(注意:应该需要切割“/postcheck”,如果前端提示跨域需要处理一下端口的地址) = " + webStartPage);
|
49
|
49
|
|
50
|
50
|
// 允许的来源
|
51
|
51
|
String[] allowDomain = {
|
|
@@ -54,9 +54,9 @@ public class RestCorsFilter implements Filter {
|
54
|
54
|
"http://10.152.72.7:8180" // 岗检JAVA接口
|
55
|
55
|
// "*.cnooc.*"
|
56
|
56
|
// TODO 打包屏蔽-甲方部署时注释:甲方不需要本地登录功能采用单点登录
|
57
|
|
- , "http://192.168.3.187:8181" // 前端开发-王宇
|
58
|
|
- , "http://192.168.3.32:81" // 前端开发-李帅
|
59
|
|
- , "http://192.168.3.200:8181" // 前端开发
|
|
57
|
+// , "http://192.168.3.187:8181" // 前端开发-王宇
|
|
58
|
+// , "http://192.168.3.32:81" // 前端开发-李帅
|
|
59
|
+// , "http://192.168.3.200:8181" // 前端开发
|
60
|
60
|
};
|
61
|
61
|
Set<String> allowedOrigins = new HashSet<>(Arrays.asList(allowDomain));
|
62
|
62
|
String originHeader = request.getHeader("Origin");
|
|
@@ -65,9 +65,9 @@ public class RestCorsFilter implements Filter {
|
65
|
65
|
//前端的头Origin为空时设置为前端Nginx的地址
|
66
|
66
|
//前端跳转方式:src/views/postcheck.vue -> window.location.href = `${this.getBaseUrl()}/redirectpostcheck`;
|
67
|
67
|
if (StringUtils.isBlank(originHeader)) {
|
68
|
|
-// originHeader = "http://10.152.72.7:8181";//岗检前端Nginx
|
|
68
|
+ originHeader = "http://10.152.72.7:8181";//岗检前端Nginx
|
69
|
69
|
// originHeader = "http://10.152.72.7:8180";//岗检JAVA接口
|
70
|
|
- originHeader = "http://192.168.3.32:81";//李帅
|
|
70
|
+// originHeader = "http://192.168.3.32:81";//李帅
|
71
|
71
|
// originHeader = "http://192.168.3.187:8181";//王宇
|
72
|
72
|
log.info("【跨域过滤器】拿到请求中的request.getHeader(\"Origin\") 等于空,服务器设置默认值后 = {}", originHeader);
|
73
|
73
|
}
|