mod
This commit is contained in:
+16
-2
@@ -233,9 +233,23 @@ public class ConsoleSecurityConfiguration implements BeanClassLoaderAware {
|
||||
* @return {@link HeadersConfigurer}
|
||||
*/
|
||||
public Customizer<CorsConfigurer<HttpSecurity>> withCorsConfigurerDefaults() {
|
||||
CorsConfiguration configuration = new CorsConfiguration()
|
||||
.setAllowedOriginPatterns(Lists.newArrayList(ALL)).applyPermitDefaultValues();
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
// 显式配置允许的源(支持凭证时不能使用 *)
|
||||
configuration.setAllowedOrigins(Lists.newArrayList(
|
||||
"http://100.74.125.93:1898",
|
||||
"http://100.74.125.93:1989",
|
||||
"http://100.74.125.93:1988",
|
||||
"http://localhost:1898",
|
||||
"http://localhost:1989",
|
||||
"http://localhost:1988",
|
||||
"http://localhost:3000",
|
||||
"http://localhost:3001"
|
||||
));
|
||||
configuration.setAllowCredentials(true);
|
||||
configuration.setAllowedMethods(Lists.newArrayList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
|
||||
configuration.setAllowedHeaders(Lists.newArrayList("*"));
|
||||
configuration.setExposedHeaders(Lists.newArrayList("Set-Cookie", "Authorization", "X-Requested-With"));
|
||||
configuration.setMaxAge(3600L);
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
return configurer -> configurer.configurationSource(source);
|
||||
|
||||
+15
-2
@@ -72,9 +72,22 @@ public class AbstractSecurityConfiguration {
|
||||
*/
|
||||
public Customizer<CorsConfigurer<HttpSecurity>> withCorsConfigurerDefaults() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
configuration.setAllowedOriginPatterns(Lists.newArrayList(ALL));
|
||||
configuration.applyPermitDefaultValues();
|
||||
// 显式配置允许的源(支持凭证时不能使用 *)
|
||||
configuration.setAllowedOrigins(Lists.newArrayList(
|
||||
"http://100.74.125.93:1898",
|
||||
"http://100.74.125.93:1989",
|
||||
"http://100.74.125.93:1988",
|
||||
"http://localhost:1898",
|
||||
"http://localhost:1989",
|
||||
"http://localhost:1988",
|
||||
"http://localhost:3000",
|
||||
"http://localhost:3001"
|
||||
));
|
||||
configuration.setAllowCredentials(true);
|
||||
configuration.setAllowedMethods(Lists.newArrayList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
|
||||
configuration.setAllowedHeaders(Lists.newArrayList("*"));
|
||||
configuration.setExposedHeaders(Lists.newArrayList("Set-Cookie", "Authorization", "X-Requested-With"));
|
||||
configuration.setMaxAge(3600L);
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
return configurer -> configurer.configurationSource(source);
|
||||
|
||||
Reference in New Issue
Block a user