When there is information regarding refresh + access token pair there is always the following flow presented in case access token expires:
- do request / check expiration
- see the token expires
- get new access token via auth API
- retry the request with a new access token
And I don't understand the main idea... Why should we invalidate the initial request, force frontend to wait, request different API, request again, to proceed with the initial request.
Why backend doesn't refresh an access token automatically if the user is valid and has a valid refresh token in headers? (which can be done e.g. via middleware)
Is having such middleware is a viable solution or there something I don't see?