spierce7
07/27/2019, 10:17 PMstatic
block for some image requests (i.e. /favicon-32x32.png
) aren't found and get returned with the redirect, but when I comment out the redirectUnknown
function, it works fine. It's odd because my static
block is placed before redirectUnknown
. Does anyone know of a better way to do this?
fun Route.redirectUnknown() {
// Unknown path - redirect back to main site
get("*") {
val domain = call.request.domain()
val port: String = run {
val port = call.request.port()
if (port == 80 || port == 443) "" else ":$port"
}
val redirectUrl: String = if (BuildUtil.isDev) {
val scheme = call.request.origin.scheme
if (domain.value == "localhost" || domain.isIpAddress()) {
"$scheme://$domain$port/"
} else {
"$<scheme://www>.$domain$port/"
}
} else {
"<https://www>.$domain$port/"
}
call.respondRedirect(redirectUrl)
}
}
Big Chungus
07/28/2019, 10:55 AMspierce7
07/28/2019, 6:35 PM