I have working on angular 7 applications and implement rest API calling using httpClient. API works sometime perfectly and sometimes coming below error with status 403:

`Access to XMLHttpRequest at 'API URL' from origin 'API server' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`

Once this error coming in any of one API after that every API stop the working.

For this applications backend server doe in JAVA. In java, added below code for cross origin allow to access from frontend.

```
    public FilterRegistrationBean<CorsFilter> corsFilter() {
        final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        final CorsConfiguration config = new CorsConfiguration();

        config.setAllowedOrigins(Arrays.asList(CorsConfiguration.ALL));
        config.setAllowedHeaders(Arrays.asList(CorsConfiguration.ALL));
        config.setAllowedMethods(Arrays.asList(CorsConfiguration.ALL));
        config.setMaxAge(3600L);
        config.setAllowCredentials(true);

        source.registerCorsConfiguration("/**", config);
        FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<CorsFilter>(new CorsFilter(source));
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }```

Please help me out for this.

```