https://kotlinlang.org logo
#ktor
Title
# ktor
h

hawklike

04/11/2022, 7:35 PM
TL;DR Is there a way how to react to the unauthorized response by the Authentication feature, i.e. do something before (automatically) returning the 401 response? Hi, I have deployed my Ktor app to Heroku. When I make a POST request that uploads a file (via multipart/form-data) while the user is not authorized (token has expired), I got the 401 response as intended on my localhost. I use JWT and the Authentication feature. However, the app on Heroku responds with 503 Server Request Interrupted. It only happens when the token is invalid and the 401 should be returned. What I have found so far is that the socket is connected, some data was sent as part of a response, but then the socket was destroyed without completing the response. My question is, is there a way how to react to the unauthorized response by the Authentication feature, i.e. do something before (automatically) returning the 401 response? In my case catching an exception?
n

nschulzke

04/11/2022, 9:43 PM
Have you already tried the status pages plugin? https://ktor.io/docs/status-pages.html
h

hawklike

04/12/2022, 9:34 AM
Forgot about this option, thank you. It actually resolved my issue :)
4 Views