xiaoyong931011
2023-10-27 b6cfeee9e1df352d40ee17c94bf276b7a514226d
src/main/java/cc/mrbird/febs/common/configure/WebMvcConfigure.java
@@ -2,6 +2,7 @@
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;
@@ -21,5 +22,21 @@
        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/unipay/unipayCallBack");
        registration.excludePathPatterns("/api/unipay/agreeMentPayCallBack");
        registration.excludePathPatterns("/api/unipay/singlePayCallBack");
    }
    @Override
    public void addCorsMappings( CorsRegistry registry) {
        registry.addMapping("/**")//允许请求路径
                .allowedOrigins("*")//表示允许所有网址发起跨域请求
                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")//表示允许跨域请求的方法
                .maxAge(3600)//表示在3600秒内不需要再发送预校验请求
                .allowCredentials(true);//允许客户端携带验证信息,即允许携带cookie
    }
}