Nhu Nguyen 6 years ago
parent
commit
0cf157de43
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      src/main/java/com/example/demo/DemoApplication.java

+ 12
- 0
src/main/java/com/example/demo/DemoApplication.java View File

3
 import org.springframework.boot.SpringApplication;
3
 import org.springframework.boot.SpringApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5
 import org.springframework.context.annotation.Bean;
5
 import org.springframework.context.annotation.Bean;
6
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
6
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7
 
9
 
8
 @SpringBootApplication
10
 @SpringBootApplication
9
 public class DemoApplication {
11
 public class DemoApplication {
11
 	public static void main(String[] args) {
13
 	public static void main(String[] args) {
12
 		SpringApplication.run(DemoApplication.class, args);
14
 		SpringApplication.run(DemoApplication.class, args);
13
 	}
15
 	}
16
+
17
+	@Bean
18
+	public WebMvcConfigurer corsConfigurer() {
19
+		return new WebMvcConfigurerAdapter() {
20
+			@Override
21
+			public void addCorsMappings(CorsRegistry registry) {
22
+				registry.addMapping("*").allowedOrigins("http://localhost:9000");
23
+			}
24
+		};
25
+	}
14
 }
26
 }