Michael Evans
01/07/2022, 11:49 PMval port = System.getenv("PORT")?.toInt() ?: 9090
embeddedServer(Netty, port = port) {
routing {
get("/") {
call.respondText(
this::class.java.classLoader.getResource("index.html")!!.readText(),
ContentType.Text.Html
)
}
static("/static") {
resources("")
}
}
}.start(wait = true)
When running on my localhost, this responds just fine. And when running in heroku, I get the log output that tells me it did start up the server on the port heroku defines:
[main] INFO ktor.application - Responding at <http://0.0.0.0:55278>
But then when I try to load the heroku app from the browser, I get an error, and the heroku logs say: "Connection closed without response"
heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=<http://melomidi.herokuapp.com|melomidi.herokuapp.com> request_id=e0cdaa83-eaa4-4733-a51f-947de463c433 fwd="174.246.82.169" dyno=web.1 connect=0ms service=13ms status=503 bytes=0 protocol=http
I have tried with both http and https. I have also tried loading static/index.html directly and got the same result.
I've also tried adding a SERVER_HOST env var and using that to change the default 0.0.0.0 host to various things, like localhost, 127.0.0.1 and melomidi.herokuapp.com but those resulted in other errors where the server failed to start up.
Anyone have any suggestions? Thanks in advance!