Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.navan.heroesbackend;
- import java.util.Arrays;
- 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;
- @Configuration
- public class CorsConfig {
- @Bean
- public CorsFilter corsFilter() {
- CorsConfiguration config = new CorsConfiguration();
- config.addAllowedOrigin("*");
- config.addAllowedHeader("*");
- config.setAllowedMethods(Arrays.asList(
- new String[] {"OPTIONS", "GET", "POST", "PUT", "DELETE"}));
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- source.registerCorsConfiguration("/**", config);
- return new CorsFilter(source);
- }
- }
Add Comment
Please, Sign In to add comment