-
Notifications
You must be signed in to change notification settings - Fork 41.2k
@CrossOrigin with @RepositoryRestResource doesn't work in Spring Boot 2.2 M2 #16683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think we changed anything in Boot related to CORS. There were some Spring Framework though that seem related. @sdeleuze could you take a look, please? |
If I add a @Bean
public FilterRegistrationBean<CorsFilter> simpleCorsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.setAllowedOrigins(Collections.singletonList("http://localhost:4200"));
config.setAllowedMethods(Collections.singletonList("*"));
config.setAllowedHeaders(Collections.singletonList("*"));
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
} |
@christophstrobl Could you (or somebody else from Spring Data REST team) please have a look if Spring Data REST has been updated to leverage |
Doesn't look like there's anything we can do in Boot about this so I'll go ahead and close this one. @mraible Please open an issue with Spring Data REST. |
I've filed DATAREST-1372 for further investigation. @mraible – Do you think you can strip the problem down into a plain Java based test case. I'm afraid we can't and don't want to run anything JavaScript related in the Spring Data REST test base. Also it would help by removing hopefully unrelated aspects from the picture. |
@odrotbohm I have added a link to the related upgrade guidelines in the JIRA issue. I warned and helped Boot team to handle these changes, but indeed forgot to warn you as well, apology for that. That's said it is surprising the tests still work if CORS handling is broken. |
This also works:
|
I tried to recreate my Build a Basic CRUD App with Angular 7.0 and Spring Boot 2.1 using Spring Boot 2.2 and Angular 8 today. I made it up until the point of adding a new Car from the Angular client. When I try to do that, I get a CORS error from Spring Boot.
In Spring Boot 2.1, I was able to do the following and this no longer seems to work:
Steps to reproduce:
Then, in another terminal:
Open http://localhost:4200 and click on Add, then enter a name and click Save.
The text was updated successfully, but these errors were encountered: