I deployed a Python Flask app which authenticates the user and then makes API requests to the backend endpoints.
While authentication works perfectly when using the app locally, once I deploy the app to DigitalOcean, sometimes the app randomly gets a 401 error when making API requests. When I make the request again by pressing the button on the frontend, it works. This behaviour is completely random.
I've tried using both the Flask-Login and Flask-Securitiy-Too libraries and the same issue happens with them both.
I deployed the exact same app on DigitalOcean 3 month3 ago and was not getting this 401 error during my 3 months of testing and prod usage.
As far as I can tell, this is because of missing CSRF tokens (this is the error I got while debugging Flask-Login).
Any help is highly appreciated.