I am working on a web app where Flask is used as backend and react as frontend. I was wondering if flask's flask-login extension which handle login and logout of users, can be used in this scenario. Flask is purely used at server side and deals with only API requests and sends response to frontend. Can flask-login handle user authentication and management (login/logout) in such case?
Thanks!
CodePudding user response:
Yes, Flask-Login can still be used if Flask is only being used on the server-side (or backend) of an application. Flask-Login is a Flask extension that provides user session management, which is useful for maintaining user authentication and access control in a Flask application. It works by adding a layer of functionality to the Flask application that handles common tasks related to user sessions, such as logging users in and out, and checking whether a user is authenticated before allowing them to access certain routes or views in the application.
Flask-Login can still work if Flask is only being used at the server-side (backend) and the frontend is hosted on a different machine. Flask-Login uses cookies and sessions to handle user authentication, and these can be shared across different machines as long as they are on the same domain. As long as the frontend and backend are configured to communicate with each other, Flask-Login will be able to handle user authentication on the backend.