1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| @Component public class CrossInterceptor implements Filter {
private final Logger logger = LoggerFactory.getLogger(CrossInterceptor.class);
@Override public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.addHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.addHeader("Access-Control-Allow-Headers", "Content-Type,clientType,Access-Token,doctorId,token"); response.setHeader("Access-Control-Expose-Headers", "*"); response.addHeader("Access-Control-Max-Age", "1800"); chain.doFilter(request, response); }
@Override public void init(FilterConfig filterConfig) throws ServletException {
}
@Override public void destroy() {
} }
|