# http4k

Philipp Mayer

04/01/2021, 8:08 PM
Hey guys, not sure if I'm missing something, but I ran into a weird issue with the Apache Backend. Setting up my server with
Copy code
val server = DebuggingFilters.PrintRequest()
        .then(PowerSocketSwitcherApp(powerSwitch, config.sockets))
Will let me access it from inside the local network. But when I swap out SunHttp for Apache, I get a response "not authoritative". I just found that issue, but it's more centered around the work load it seems: Btw, my CorsFilter:
Copy code
val CorsFilter = ServerFilters.Cors(
            originPolicy = AllowAllOriginPolicy,
            headers = listOf("*"),
            methods = Method.values().toList(),
            credentials = false
Do you have any hints? Thanks in advance!


04/01/2021, 8:57 PM
I couldn't reproduce, at least not with my adapted example:
Copy code
import org.http4k.client.JavaHttpClient
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status
import org.http4k.core.then
import org.http4k.filter.CorsPolicy
import org.http4k.filter.DebuggingFilters
import org.http4k.filter.ServerFilters
import org.http4k.server.ApacheServer
import org.http4k.server.asServer

fun main() {
        .then { Response(Status.OK) }
        .asServer(ApacheServer(9090)).start().use {
            val client = JavaHttpClient()
            println(client(Request(Method.GET, "<http://localhost:9090>")))
Can you please try that and let us know if we're missing something?

Philipp Mayer

04/02/2021, 3:53 PM
That's working and my tests are working too. But as soon as my client has a different IP (e.g. calling the service from my smartphone) I get the mentioned error.
I thought it must have something to do with my network, but the error doesn't appear when I switch Apache for SunHttp.


04/03/2021, 10:16 AM
Not sure that it helps but I also had a problem accessing localhost in cloudfoundry with apache server I gave up and switched to Undertow.