Unable to Redirect After Login when Using `on_session_creation`

I am facing an issue with the on_session_creation function after a successful login. Despite receiving the desired page as a response in the network tab, the redirection is not occurring as expected. I have verified that the on_session_creation is being called after login, but for some reason, the redirection is not taking place. This is hindering the expected flow of the application. Any insights or guidance on resolving this redirection problem would be greatly appreciated.

#hooks.py
on_session_creation = [
    "custom_app.utils.redirect_on_login"
]
#custom_app/utils/__init__.py
def redirect_on_login():
    #....code
    link = f"http://localhost:8000/update-password?key={key}"
    frappe.local.response["type"] = "redirect"
    frappe.local.response["location"] = link

Network tab