Skip to content

Commit

Permalink
feature: cors 관련 설정을 추가한다 (#24)
Browse files Browse the repository at this point in the history
* feat: cors configuration 추가

* refactor: CacheConfig 이름 및 패키지 변경
  • Loading branch information
Combi153 authored Jan 29, 2024
1 parent 8ab5b18 commit bd5313a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.petqua.common.cofig
package com.petqua.common.config

import org.springframework.cache.CacheManager
import org.springframework.cache.annotation.EnableCaching
Expand All @@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration

@EnableCaching
@Configuration
class CacheConfiguration {
class CacheConfig {

@Bean
fun cacheManager(): CacheManager {
Expand Down
30 changes: 30 additions & 0 deletions src/main/kotlin/com/petqua/common/config/CorsConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.petqua.common.config

import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod.DELETE
import org.springframework.http.HttpMethod.GET
import org.springframework.http.HttpMethod.OPTIONS
import org.springframework.http.HttpMethod.PATCH
import org.springframework.http.HttpMethod.POST
import org.springframework.http.HttpMethod.PUT
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class CorsConfig : WebMvcConfigurer {

override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "https://petqua.co.kr")
.allowedMethods(
OPTIONS.name(),
GET.name(),
POST.name(),
PUT.name(),
PATCH.name(),
DELETE.name(),
)
.allowCredentials(true)
.exposedHeaders("*")
}
}

0 comments on commit bd5313a

Please sign in to comment.