Browse Source

simple rest

herlanS_ 5 years ago
parent
commit
ca877f2b9e

+ 12 - 0
src/main/kotlin/com/kawanansemut/demoangular/DemoAngularApplication.kt

@@ -5,8 +5,11 @@ import com.kawanansemut.demoangular.entities.UserRepository
 import org.springframework.boot.autoconfigure.SpringBootApplication
 import org.springframework.boot.context.event.ApplicationReadyEvent
 import org.springframework.boot.runApplication
+import org.springframework.context.annotation.Configuration
 import org.springframework.context.event.EventListener
 import org.springframework.stereotype.Component
+import org.springframework.web.servlet.config.annotation.CorsRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
 
 @SpringBootApplication
 class DemoAngularApplication
@@ -30,3 +33,12 @@ class justAfterStart(
 
 
 }
+
+@Configuration
+class MvcConfig : WebMvcConfigurer {
+
+	override fun addCorsMappings(registry: CorsRegistry) {
+		registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*")
+				.allowedHeaders("*")
+	}
+}