Skip to content
Snippets Groups Projects
Commit dd70f940 authored by Ján Dovjak's avatar Ján Dovjak
Browse files

feat: CORS

parent 0a96e02c
No related branches found
No related tags found
No related merge requests found
......@@ -2,11 +2,15 @@ package cz.muni.fi.pa165.icehockeymanager.rest.config;
import cz.muni.fi.pa165.icehockeymanager.config.ApplicationConfig;
import cz.muni.fi.pa165.icehockeymanager.config.PersistanceApplicationConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableTransactionManagement
......@@ -14,4 +18,15 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Import(ApplicationConfig.class)
@ComponentScan(basePackages = "cz.muni.fi.pa165.icehockeymanager")
public class RestConfiguration {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedOrigins("http://localhost:4200/");
}
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment