修改命名
This commit is contained in:
parent
8eb80c7b65
commit
1b9e0a8f4f
@ -0,0 +1,30 @@
|
|||||||
|
package com.yunan.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
import org.springframework.web.filter.CorsFilter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class GlobalCorsConfig {
|
||||||
|
/**
|
||||||
|
* 解决跨域问题
|
||||||
|
* @return {@link CorsFilter }
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CorsFilter corsFilter() {
|
||||||
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
|
// 设置你要允许的网站域名
|
||||||
|
config.addAllowedOrigin("http://localhost:3100");
|
||||||
|
//允许跨域发送cookie
|
||||||
|
config.setAllowCredentials(true);
|
||||||
|
//放行全部原始头信息
|
||||||
|
config.addAllowedHeader("*");
|
||||||
|
//允许所有请求方法跨域调用
|
||||||
|
config.addAllowedMethod("*");
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", config);
|
||||||
|
return new CorsFilter(source);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user