|
61 | 61 | import org.springframework.boot.web.servlet.ServletRegistrationBean; |
62 | 62 | import org.springframework.context.annotation.Bean; |
63 | 63 | import org.springframework.context.annotation.Configuration; |
| 64 | +import org.springframework.web.cors.CorsConfiguration; |
64 | 65 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
65 | 66 | import org.springframework.web.filter.CorsFilter; |
66 | 67 | import org.springframework.web.servlet.DispatcherServlet; |
67 | | -import org.springframework.web.servlet.config.annotation.CorsRegistryWorkaround; |
68 | 68 |
|
69 | 69 | import javax.annotation.PostConstruct; |
70 | 70 | import javax.servlet.MultipartConfigElement; |
| 71 | +import java.util.LinkedHashMap; |
71 | 72 | import java.util.List; |
72 | 73 | import java.util.Map; |
73 | 74 | import java.util.Optional; |
|
88 | 89 | @EnableConfigurationProperties({GraphQLServletProperties.class}) |
89 | 90 | public class GraphQLWebAutoConfiguration { |
90 | 91 |
|
| 92 | + |
91 | 93 | public static final String QUERY_EXECUTION_STRATEGY = "queryExecutionStrategy"; |
92 | 94 | public static final String MUTATION_EXECUTION_STRATEGY = "mutationExecutionStrategy"; |
93 | 95 | public static final String SUBSCRIPTION_EXECUTION_STRATEGY = "subscriptionExecutionStrategy"; |
@@ -143,8 +145,12 @@ public GraphQLErrorStartupListener graphQLErrorStartupListener() { |
143 | 145 | @ConditionalOnClass(CorsFilter.class) |
144 | 146 | @ConditionalOnProperty(value = "graphql.servlet.corsEnabled", havingValue = "true", matchIfMissing = true) |
145 | 147 | public CorsFilter corsConfigurer() { |
| 148 | + Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<>(1); |
| 149 | + CorsConfiguration corsConfiguration = new CorsConfiguration().applyPermitDefaultValues(); |
| 150 | + corsConfigurations.put(graphQLServletProperties.getCorsMapping(), corsConfiguration); |
| 151 | + |
146 | 152 | UrlBasedCorsConfigurationSource configurationSource = new UrlBasedCorsConfigurationSource(); |
147 | | - configurationSource.setCorsConfigurations(CorsRegistryWorkaround.getCorsConfiguration(graphQLServletProperties.getCorsMapping())); |
| 153 | + configurationSource.setCorsConfigurations(corsConfigurations); |
148 | 154 | configurationSource.setAlwaysUseFullPath(true); |
149 | 155 |
|
150 | 156 | return new CorsFilter(configurationSource); |
|
0 commit comments