Hello! Is this correct configuration for handling unknown paths in Ktor? We use tomcat on production, but when Ktor receives GET request for unknown path then it returns 200 (only on Tomcat, on localhost it is 404). I used it as workaround and it works great, but I wanted to ask if there is any other way, or maybe if this code is somehow dangerous:
Yes, it works on local, but not on production. Most likely its related to tomcat or other proxy, but still Ktor is receiving calls, so it should automatically somehow answer to proxy that it could not find given path, weird 😞
t
Tom.K
05/28/2024, 11:42 AM
If Ktor is returning correct response, you'll have to check how Tomcat is configured as you said, if any filter is interfering or check how it handles the response from Ktor.
// <https://ktor.io/docs/server-routing.html#tailcard>
route("{...}") {
// Handler for any method and path
handle {
call.respond(status = HttpStatusCode.NotFound, message = "Nothing to see here!")
}
}