vue添加请求头跨域问题
前两天做项目用到iview,添加请求头后,后端做了跨域处理。在SpringBoot2.0没问题,换到SpringBoot 1.5.13后又出现跨域。。。下面是跨域处理代码:@Configurationpublic class CorsConfig extends WebMvcConfigurerAdapter {@Overridepublic void addCorsM...
·
前两天做项目用到iview,添加请求头后,后端做了跨域处理。在SpringBoot2.0没问题,换到SpringBoot 1.5.13后又出现跨域。。。下面是跨域处理代码:
@Configuration public class CorsConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**"). allowedOrigins("*"). allowedMethods("DELETE","GET", "POST", "OPTIONS", "PUT") .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers") .exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials") .allowCredentials(true).maxAge(3600); } }
改成如下代码后解决
@Configuration public class CorsConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**"). allowedOrigins("*"). allowedMethods("DELETE","GET", "POST", "OPTIONS", "PUT") .allowedHeaders("*") .allowCredentials(true).maxAge(3600); } }
感觉是vue把请求头封装,还增加了其他请求头内容,所以用枚举会出现跨域问题...
更多推荐
已为社区贡献1条内容
所有评论(0)