I do not think I understand `StatusPages` plugin ...
# ktor
a
I do not think I understand
StatusPages
plugin correctly. I am trying to redirect the user to “/” if they try to navigate to a page that does not exist (say they go to “/invalid”, then the browser should redirect to “/” instead). I was under the impression that I would have to use StatusPages for this like so:
Copy code
install(StatusPages) {
        status(HttpStatusCode.NotFound) {
            call.respondRedirect("/")
        }
but when I navigate to “/invalid” the browser displays a blank page and the console shows a 404 for “/invalid”. I set a breakpoint to the call but it is never triggered. Isn’t this what StatusPages are meant to handle? Would I need to use something else for this scenario? (I am thinking that maybe i could use just routing with wildcards)
k
I just checked your code and it works for me
Copy code
Request URL: <http://0.0.0.0/ILoveKotlin>
Request Method: GET
Status Code: 302 Found
Remote Address: 0.0.0.0:80
Referrer Policy: strict-origin-when-cross-origin
Connection: keep-alive
Content-Length: 0
Location: /
Maybe you put in wrong place, like some function that was not invoked during startup
👍 1
a
Thanks. I’ll check it out 👍