KKSU
2023-12-22 44d5373021f883b389d002c4c63a2b78bfbdfaf6
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;
@@ -31,4 +32,13 @@
        registration.excludePathPatterns("/api/xcxPay/rechargeCallBack");
        registration.excludePathPatterns("/api/xcxPay/xcxCodePayCallBack");
    }
    @Override
    public void addCorsMappings( CorsRegistry registry) {
        registry.addMapping("/**")//允许请求路径
                .allowedOrigins("*")//表示允许所有网址发起跨域请求
                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")//表示允许跨域请求的方法
                .maxAge(3600)//表示在3600秒内不需要再发送预校验请求
                .allowCredentials(true);//允许客户端携带验证信息,即允许携带cookie
    }
}