import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 跨域配置
*/
@Configuration
public class CrossConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedHeaders("*")
.allowedMethods("GET", "POST", "DELETE", "PUT", "HEAD", "OPTIONS")
.allowCredentials(true)
.maxAge(3600);
}
}
SpringBoot + Vue 前后端分离项目 跨域问题解决方案(一)
最新推荐文章于 2024-03-25 17:44:17 发布