feat(新增): 解决跨域
This commit is contained in:
parent
919e428e9e
commit
77cbffcd06
|
@ -0,0 +1,22 @@
|
||||||
|
package com.atguigu.config;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||||
|
/**
|
||||||
|
* * 解决跨域
|
||||||
|
*
|
||||||
|
* @param registry 跨域注册表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/**")// 添加路径规则
|
||||||
|
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
|
||||||
|
.allowedOriginPatterns("*")// 允许请求来源的域规则
|
||||||
|
.allowedMethods("*")
|
||||||
|
.allowedHeaders("*");// 允许所有的请求头
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue