Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- springboot jwt example
- Constants pool
- angular jwt
- springboot-angular-jwt
- mongodb install ec2
- JWT
- jvm 메모리 구조
- HHH000104
- spring filter ordering
- String Pool
- jvm memory structure
- jwt example
- String Constants Pool
- JPA
- spring-boot-maven-plugin
- jpa pagination
- springboot maven plugin
- spring jwt
- springboot mongodb config
- 기본 Manifest 속성이 없습니다
- docker mongodb
- string comparison
- jvm memory model
- springboot jwt
- jwt token
- docker mongodb install
- install mongodb docker
- jvm 모델
- filter ordering
- intern
Archives
- Today
- Total
개발블로그
Spring WebFlux CORS Configuration 본문
Spring Webflux with java로 이용할 때에는 WebFluxConfigurer를 구현했다.
@Configuration
@EnableWebFlux
class WebConfig: WebFluxConfigurer
{
override fun addCorsMappings(registry: CorsRegistry)
{
registry.addMapping("/**")
.allowedOrigins("*") // any host or put domain(s) here
.allowedMethods("GET","POST","OPTIONS") // put the http verbs you want allow
.allowedHeaders("*") // put the http headers you want allow
.allowCredentials(true)
}
}
그랬을 때, CORS 문제는 없었다.
kotlin에서도 문제 없을거라 생각하고 동일하게 사용했는데,
post 요청에 대해서만 CORS 문제가 계속 발생했다.
get 요청에 대해서는 문제가 없는걸로 봐서는,
allowedHeader가 계속 적용이 안되는 느낌이었다..
그런 와중 Baeldung의 문서를 다시 읽었다.
위 방법보다는 Filter를 설정하는 방법을 권장한다고 하여, 바꿔보았다.
@Component
class CorsFilter {
@Bean
fun corsWebFilter(): CorsWebFilter {
val corsConfig = CorsConfiguration()
corsConfig.addAllowedOrigin("*")
corsConfig.maxAge = 8000L
corsConfig.addAllowedMethod(HttpMethod.GET)
corsConfig.addAllowedMethod(HttpMethod.POST)
corsConfig.addAllowedMethod(HttpMethod.OPTIONS)
corsConfig.addAllowedHeader("Content-Type")
val source = UrlBasedCorsConfigurationSource()
source.registerCorsConfiguration("/**", corsConfig)
return CorsWebFilter(source)
}
}
그랬더니, 잘 동작한다..
정확한 원인을 모르고, 대안을 찾아서 굉장히 찝찝하다ㅠㅠ..
'Spring' 카테고리의 다른 글
springboot- kafka create dynamically (0) | 2019.06.19 |
---|---|
Spring data mongodb nested array 추가/수정/삭제 (1) | 2019.06.04 |
Springboot-Angular-JWT기반 A/A기능 구현(2) (0) | 2019.04.24 |
Springboot-Angular-JWT기반 A/A기능 구현(1) (0) | 2019.03.28 |
JWT(Json Web Token)란? (0) | 2019.03.13 |
Comments