Skip to content
Snippets Groups Projects
Commit e4bf73af authored by Brice Copy's avatar Brice Copy
Browse files

Add support for CORS

parent e902a8c7
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -17,6 +17,8 @@ import org.springframework.context.annotation.Bean; ...@@ -17,6 +17,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
...@@ -34,6 +36,13 @@ public class C2MonAtmosphereApplication extends SpringBootServletInitializer { ...@@ -34,6 +36,13 @@ public class C2MonAtmosphereApplication extends SpringBootServletInitializer {
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index.html"); registry.addViewController("/").setViewName("forward:/index.html");
} }
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(CorsConfiguration.ALL)
.allowedMethods("PUT", "DELETE","GET", "POST", "HEAD", "OPTIONS");
}
} }
@Bean @Bean
...@@ -51,6 +60,7 @@ public class C2MonAtmosphereApplication extends SpringBootServletInitializer { ...@@ -51,6 +60,7 @@ public class C2MonAtmosphereApplication extends SpringBootServletInitializer {
registration.setLoadOnStartup(0); registration.setLoadOnStartup(0);
// Need to occur before the EmbeddedAtmosphereInitializer // Need to occur before the EmbeddedAtmosphereInitializer
registration.setOrder(Ordered.HIGHEST_PRECEDENCE); registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
//registration.addInitParameter("org.atmosphere.cpr.AtmosphereInterceptor", "org.atmosphere.interceptor.CorsInterceptor,org.atmosphere.interceptor.HeartbeatInterceptor");
return registration; return registration;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment