com.arextest.web.api.service.beans.GlobalCrossOriginConfiguration Maven / Gradle / Ivy
package com.arextest.web.api.service.beans;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* @author jmo
* @since 2022/1/31
*/
@SpringBootConfiguration
public class GlobalCrossOriginConfiguration {
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.applyPermitDefaultValues();
UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource();
corsConfigurationSource.registerCorsConfiguration("/**", config);
return new CorsFilter(corsConfigurationSource);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy