CORS
Allow a browser frontend running on a different origin to call your API. The extension handles preflights and adds the matching CORS headers to responses.
List allowed origins, methods and headers. Install CORS before extensions that can return a response early.
CORS configurationimplementation("codes.draeger:ktserve-cors:0.0.0-dev")
import codes.draeger.ktserve.*
import codes.draeger.ktserve.cors.*
fun main() = serve {
install(cors {
allowOrigins("https://app.example")
allowMethods("GET")
allowHeaders("Authorization")
})
get("/status") { text("ok") }
}