package cc.mrbird.febs.common.configure; import cc.mrbird.febs.common.interceptor.LoginInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author xxx * @date 2020-08-24 **/ @Configuration public class WebMvcConfigure implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor()); registration.addPathPatterns("/api/**"); registration.excludePathPatterns("/api/login/**"); registration.excludePathPatterns("/api/common/**"); registration.excludePathPatterns("/api/category/**"); registration.excludePathPatterns("/api/goods/**"); registration.excludePathPatterns("/api/pay/**"); registration.excludePathPatterns("/api/news/**"); registration.excludePathPatterns("/api/member/cashOutSetting"); registration.excludePathPatterns("/api/member/agentDetail"); registration.excludePathPatterns("/api/member/activityInfo"); registration.excludePathPatterns("/api/leader/leaderList"); registration.excludePathPatterns("/api/leader/leaderListInFence"); registration.excludePathPatterns("/api/leader/noLoginLeaderTitle"); registration.excludePathPatterns("/api/xcxPay/wxpayCallback"); registration.excludePathPatterns("/api/xcxPay/rechargeCallBack"); registration.excludePathPatterns("/api/wechat/reply/event"); } /** * 设置cors跨域支持 * * @param registry */ @Override public void addCorsMappings(CorsRegistry registry){ //设置允许跨域的路径 registry.addMapping ("/**") //设置允许跨域请求的域名 .allowedOrigins ("*") //是否允许证书 .allowCredentials (true) //设置允许的方法 .allowedMethods ("GET","POST", "OPTIONS") //设置允许的header属性 .allowedHeaders ("*") //允许跨域时间 .maxAge (3600); } }