//package com.liquidnet.common.web.filter;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Slf4j
//@Configuration
//public class CrossDomainFilter implements Filter {
//
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletResponse resp = (HttpServletResponse)servletResponse;
//        HttpServletRequest req = (HttpServletRequest)servletRequest;
//        //获取请求的源
//        String url = req.getHeader("Origin");
//        resp.setHeader("Access-Control-Allow-Origin", url);
//        resp.setHeader("Access-Control-Allow-Headers", "X-Requested-With, accept, content-type, token, xxxx");
//        resp.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
//        resp.setHeader("Access-Control-Allow-Credentials", "true");
//        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
//        String requestMethod = httpServletRequest.getMethod();
//        if ("OPTIONS".equalsIgnoreCase(requestMethod)) {
//            return;
//        }
//        filterChain.doFilter(servletRequest, servletResponse);
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}
