Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit c11a84f

Browse files
committed
simplify cors enabled property (fixes #682)
1 parent f94d3ab commit c11a84f

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/autoconfigure/web/servlet/CorsEnabledCondition.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,25 @@ public GraphQLErrorStartupListener graphQLErrorStartupListener(
129129

130130
@Bean
131131
@ConditionalOnClass(CorsFilter.class)
132-
@Conditional(CorsEnabledCondition.class)
132+
@ConditionalOnProperty(
133+
prefix = "graphql.servlet",
134+
name = "cors-enabled",
135+
havingValue = "true",
136+
matchIfMissing = true)
133137
@ConfigurationProperties("graphql.servlet.cors")
134138
public CorsConfiguration corsConfiguration() {
135139
return new CorsConfiguration();
136140
}
137141

138142
@Bean
139143
@ConditionalOnClass(CorsFilter.class)
140-
@Conditional(CorsEnabledCondition.class)
144+
@ConditionalOnProperty(
145+
prefix = "graphql.servlet",
146+
name = "cors-enabled",
147+
havingValue = "true",
148+
matchIfMissing = true)
141149
public CorsFilter corsConfigurer(CorsConfiguration corsConfiguration) {
150+
log.info("Enabling cors filter");
142151
Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<>(1);
143152
if (corsConfiguration.getAllowedMethods() == null) {
144153
corsConfiguration.setAllowedMethods(

0 commit comments

Comments
 (0)