後端跨域配置類
阿新 • • 發佈:2022-05-26
@Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**")//所有介面都支援跨域 .allowedOriginPatterns("*")//所有地址都可訪問 .allowCredentials(true) .allowedMethods("*")//"GET","HEAD","POST","PUT","DELETE","OPTIONS" .maxAge(3600);//TRANSLATE with x English TRANSLATE with EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget:允許跨域時間 } }