|
@@ -5,11 +5,13 @@ import com.bizmatics.common.core.exception.BusinessException;
|
|
|
import com.bizmatics.model.User;
|
|
|
import com.bizmatics.service.util.SessionLocal;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.elasticsearch.rest.RestRequest;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.servlet.*;
|
|
|
import javax.servlet.annotation.WebFilter;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
@@ -31,7 +33,19 @@ public class SessionFilter implements Filter {
|
|
|
|
|
|
@Override
|
|
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
|
|
|
+ HttpServletResponse httpServletResponse = (HttpServletResponse)servletResponse;
|
|
|
HttpServletRequest request = (HttpServletRequest)servletRequest;
|
|
|
+ httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ httpServletResponse.setHeader("Access-Control-Allow-Methods",
|
|
|
+ "POST, GET, OPTIONS, DELETE");
|
|
|
+ httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
|
|
|
+// httpServletResponse.setHeader("Access-Control-Allow-Headers",
|
|
|
+// "Content-Type, x-requested-with, X-Custom-Header, Request-Ajax");//允许自定义的请求头
|
|
|
+ httpServletResponse.setHeader("Access-Control-Allow-Headers", "*");
|
|
|
+ if(request.getMethod().toUpperCase().equals(RestRequest.Method.OPTIONS.name())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
String path = request.getRequestURI().substring(request.getContextPath().length()).replaceAll("[/]+$", "");
|
|
|
boolean allowedPath = ALLOWED_PATHS.contains(path);
|
|
|
if (!allowedPath){
|