Ktor proxy: forward all calls and add auth header

21 views Asked by At

i would like to implement a middelware proxy. Where all calls gets forwarded with an added header. This is what tried.

intercept(ApplicationCallPipeline.Call) {
    val targetUrl = BASE_URL + call.request.uri
    val response = client.request(targetUrl) {
        headers {
            append(HttpHeaders.Authorization, "Bearer $API_KEY")
        }
    }

    call.respond(response)
}
0

There are 0 answers