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.

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

Network tab