Enable CORS check
sitole opened this issue · 2 comments
sitole commented
Hello,
i want to connect my frontend website with Spring Kotless deployed in Lambda function, but Kotless and API gateway does not accept OPTIONS HTTP request for CORS check.
hamadycisse commented
Same issue here
mamaorha commented
hi, i had same issue i had to hack it by adding the following:
@Component
open class CorsConfiguration : OncePerRequestFilter() {
override fun doFilterInternal(
httpServletRequest: HttpServletRequest,
httpServletResponse: HttpServletResponse,
filterChain: FilterChain
) {
httpServletResponse.addHeader("Access-Control-Allow-Origin", "*")
httpServletResponse.addHeader("Access-Control-Allow-Headers", "*")
httpServletResponse.addHeader("Access-Control-Allow-Methods", "*")
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
}
after adding those go to api-gateway and enable cors per endpoint (its a pain)
- go to api gateway
- pick your api
- pick each method and go its "method response", add an http status like 200
- go to actions -> enable cors