I'm encountering an issue with my Vue.js / Express application that I can't seem to resolve.
Here's how the process unfolds:
An unauthenticated user logs into the app and is presented with the login page. Once successfully authenticated, the backend generates a JWT cookie and sends it along with the static content of the Vue.js page.
Subsequent calls to the REST API are made on the same backend which verifies the validity of the JWT. If the JWT has expired, the static content of the login page is returned.
Everything seems to be working fine, but when the browser is closed and reopened, sometimes the tab is left in memory. This causes issues if the JWT has expired since you end up with a cached version of the index page while the REST requests fail due to expired JWT.
In such scenarios, how can I redirect users back to the login page? Any assistance would be greatly appreciated. :)