Commit 051a91c9 authored by 赵啸非's avatar 赵啸非

提交配置校验

parent e828e2a5
...@@ -32,10 +32,9 @@ public class SameSiteCookieFilter implements Filter { ...@@ -32,10 +32,9 @@ public class SameSiteCookieFilter implements Filter {
String [] allowDomain= {"localhost","192.168.0.98"}; String [] allowDomain= {"localhost","192.168.0.98"};
Set allowedOrigins= new HashSet(Arrays.asList(allowDomain)); Set allowedOrigins= new HashSet(Arrays.asList(allowDomain));
String originHeader=((HttpServletRequest) request).getHeader("Origin"); String originHeader=((HttpServletRequest) request).getHeader("Origin");
if(!ObjectUtils.isEmpty(originHeader)){
URI host = URLUtil.getHost(new URL(originHeader)); URI host = URLUtil.getHost(new URL(originHeader));
String origin = host.getHost(); String origin = host.getHost();
if (allowedOrigins.contains(origin)){ if (allowedOrigins.contains(origin)){
httpResponse.setHeader("Access-Control-Allow-Origin", originHeader); httpResponse.setHeader("Access-Control-Allow-Origin", originHeader);
httpResponse.setContentType("application/json;charset=UTF-8"); httpResponse.setContentType("application/json;charset=UTF-8");
...@@ -46,6 +45,8 @@ public class SameSiteCookieFilter implements Filter { ...@@ -46,6 +45,8 @@ public class SameSiteCookieFilter implements Filter {
httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpResponse.setHeader("Access-Control-Expose-Headers", "*"); httpResponse.setHeader("Access-Control-Expose-Headers", "*");
} }
}
chain.doFilter(request, response); chain.doFilter(request, response);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment