diff --git a/build.gradle.kts b/build.gradle.kts index a2c7b8a..e806d93 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,3 @@ - import com.epages.restdocs.apispec.gradle.OpenApi3Task import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jooq.meta.jaxb.Logging @@ -130,7 +129,7 @@ tasks.withType { tasks.test { extensions.configure(JacocoTaskExtension::class) { - destinationFile = file("$buildDir/jacoco/jacoco.exec") + setDestinationFile(file("$buildDir/jacoco/jacoco.exec")) } finalizedBy(tasks.jacocoTestReport) diff --git a/src/main/kotlin/com/mjucow/eatda/common/config/WebConfig.kt b/src/main/kotlin/com/mjucow/eatda/common/config/WebConfig.kt new file mode 100644 index 0000000..24f06b2 --- /dev/null +++ b/src/main/kotlin/com/mjucow/eatda/common/config/WebConfig.kt @@ -0,0 +1,30 @@ +package com.mjucow.eatda.common.config + +import org.springframework.context.annotation.Configuration +import org.springframework.http.HttpMethod +import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.EnableWebMvc +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer +import java.time.Duration +import java.time.temporal.ChronoUnit + +@Configuration +@EnableWebMvc +class WebConfig : WebMvcConfigurer { + + override fun addCorsMappings(registry: CorsRegistry) { + registry.addMapping("/api/**") + .allowedOriginPatterns("*") + .allowedMethods( + HttpMethod.GET.name(), + HttpMethod.POST.name(), + HttpMethod.DELETE.name(), + HttpMethod.PATCH.name(), + HttpMethod.HEAD.name(), + HttpMethod.OPTIONS.name() + ) + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(Duration.of(60, ChronoUnit.MINUTES).toSeconds()) + } +}