james
06/03/2023, 1:09 PM/app
). The static home page part works well, and login/logout flow works well, but the way in which I made /app
require authentication feels hacky and seems to be buggy.. code in 🧵james
06/03/2023, 1:09 PMstaticFiles(
remotePath = "/app",
dir = File("static_app")
) {
modify { file, call ->
val currentAuthenticatedSession = getCurrentAuthenticatedSession()
if (currentAuthenticatedSession == null) {
call.respondRedirect("/login?redirectUrl=${call.request.uri}")
}
}
}
The code above shows how I’m setting up the static files route and enforcing a valid authenticated session, but the strange thing here is the behaviour when I load these routes in my browser:
• ✅ /app
works as expected when either logged out or logged in
• ✅ /app/index.html
works as expected when either logged out or logged in
• ❌ /app/
throws a 404
Does anyone have any insights as to why the trailing /
would cause this problem? Or, is there a better way to achieve what I’m trying to do?james
06/04/2023, 1:55 AMinstall(IgnoreTrailingSlash)