其他分享
首页 > 其他分享> > 后端跨域配置类

后端跨域配置类

作者:互联网

@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
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back

标签:TRANSLATE,跨域,后端,配置,location,document,true,public
来源: https://www.cnblogs.com/lyj0810/p/16313211.html