I have an angular 4 app that shows a user's information profile. The app is located in https://www.myapp.com but the user's profile picture is located in https://s3-sa-east-1.amazonaws.com/xxxx.png. The Angular app makes a Get Request to my Spring Boot Backend to obtain user profile information, but the profile image is not loaded and the browser shows me the following error:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://s3-sa-east-1.amazonaws.com/xxxx.png with MIME type application/xml. See https://www.chromestatus.com/feature/5629709824032768 for more details.
My question is how to configure my Spring Boot App in order to prevent the Cross-Origin Read Blocking (CORB)?
Next I show the security settings of my spring application:
@Configuration
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
private UserDetailsService userDetailsService;
private BCryptPasswordEncoder bCryptPasswordEncoder;
public WebSecurity(UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userDetailsService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.authorizeRequests().antMatchers(HttpMethod.POST, USER_REGISTRATION_URL).permitAll()
.antMatchers(HttpMethod.POST, RETURN_DATA).permitAll()
.anyRequest().authenticated()
.and().addFilter(new JWTAuthenticationFilter(authenticationManager(), getApplicationContext()))
.addFilter(new JWTAuthorizationFilter(authenticationManager(), getApplicationContext()))
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.addAllowedOrigin("*");
configuration.addAllowedHeader("*");
configuration.setAllowedMethods(Arrays.asList("GET","POST","PUT","PATCH","DELETE","OPTIONS"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
I would like to understand why this happens despite the configuration shown, it should be enough.
Many Thanks!