JAVA_CORS_ADVICE_FILE_CONTENT
private val JAVA_CORS_ADVICE_FILE_CONTENT: String = "
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* The {@code CORSAdvice} class is useful to set the CORS policy
*
* @author N7ghtm4r3 - Tecknobit
*/
@Configuration
public class CORSAdvice {
/**
* Method to set the CORS filter <br>
* No any-params required
*/
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(false);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
}"
JAVA_CORS_ADVICE_FILE_CONTENT
the content
of the CORSAdvice file, as Java class, to set the CORS
origin policy for the backend