Managing authentication state via a session cookie is a valid strategy, but an increasingly common approach is to use a compact JSON Web Token or JWT to manage authentication state between the back-end and frontend layers of our web application. We can store our user information inside a JWT so that the client can restore its authenticated state upon reload.
Using JWT authentication with Express and Angular
Getting ready
To use JWT in our application, we will need to install a library both in our Express web server and in our Angular application. For our web server, we will use jwt-express, a very handy and easy-to-use JWT library for Express. We will use this library to create our JWT, as well as refresh it automatically...