The code works properly in Firefox, but not Brave browser, so the issue is with the browser. I have no idea what this code does, but this seems to make the code work by adding it towards the top of my code. Here's a link to where I found the solution.
app.config.update(SESSION_COOKIE_SAMESITE="None", SESSION_COOKIE_SECURE=True)