how does nuxt prevent parallel session refresh attempts on a nested route?
one infuriating pain-point i have with Remix is that there is no sufficient way to refresh your session without each of your nested routes making the same request to refresh the session, resulting in 'n-1' wasted requests and no idempotent way of determining which one will win. ive been trying to look into how nuxt handles this, particularly for nested routes but can't seem to find a definitive answer to this issue....
1 Reply
yeah mate so ive got to use an in-house auth sdk. i get the access and refresh token on login, access tokens have a short life, 30 min i think. its easy enough to attempt a refresh on a 401, but im also managing 10+ services each using that shared access token. my issue now is if i have a service on each nested nuxt route and the token expires, ill endup making n-1 redundant calls. still waiting on remix to release their middleware feature, wondering if theres a nuxt equivilent?
ahh right yeah so all external services are called via an in-house sdk. on login, i store the tokens somewhere.
if im on products/ page, i call the products endpoint using the access token. i might have a few other components on the products page that call their respective services on page load. the issue comes with closing the browser, coming back later to that same page and the access token has expired. suddenly all services return a 401 and try to refresh the token in parallel.
just looking at ways to somehow control the session management such that i avoid a cascade of refresh requests. hope i explained that better