-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Cyprian Gracz opened SPR-15772 and commented
In my Spring Boot I have global CORS config:
@Configuration
@EnableWebMvc
public class CorsConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
CorsRegistration config = registry.addMapping("/**");
config.allowedOrigins("http://domain.com");
}
}Then I try to allow any origin to one of controllers:
@RestController
@CrossOrigin("*")
public class OpenController {
}Because of this line:
private List<String> combine(@Nullable List<String> source, @Nullable List<String> other) {
if (other == null || other.contains(ALL)) {
return (source != null ? source : Collections.emptyList());
}CorsConfiguration gets "http://domain.com" as allowed domain because controller specifies ALL ( * ) as allowed origin, so it's "ignored".
Is this desired behaviour? Shouldn't controllers/methods always override global config?
Issue Links:
- DATAREST-1184 Adapt to CORS changes in Spring Framework 5.0.3
- Add Vary: Access-Control-Request-Method/Headers CORS headers [SPR-16413] #20959 Add Vary: Access-Control-Request-Method/Headers CORS headers
Referenced from: commits 0075f13
izogfif
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement