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,7 +3,9 @@ package com.example.demo;
3 3
 import org.springframework.boot.SpringApplication;
4 4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 5
 import org.springframework.context.annotation.Bean;
6
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
6 7
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7 9
 
8 10
 @SpringBootApplication
9 11
 public class DemoApplication {
@@ -11,4 +13,14 @@ public class DemoApplication {
11 13
 	public static void main(String[] args) {
12 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
 }