Skip to content

Fix login "flash" when refreshing the page (F5) #616

@dsiguero

Description

@dsiguero

When the user is logged in, and refreshes the page (F5), it's briefly sent to the login page (/).

1. Things we've tried already (and their caveats):

  1. Tweaking the conditions in routes/_auth.tsx and routes/index.tsx to let the user through and avoid the login flash. Because we let them through the authenticated part of the app, and the loginStatus isn't success, a request (GET /user-profile) is fired w/o Authentication header, causing a 401, and triggering the token refresh again, this time through the Axios interceptor.

  2. Transient route /loading outside of _auth. This briefly "flashes" an error when refreshing the page. Not 100% sure why tbf, but it could be because we're going out and in _auth routes. Check video.

2025-08-28.00-10-33.mp4

2. Some random ideas/gut feelings that might or might not work:

  1. Decouple loginStatus from isLoading/isReloading. ATM they're all derived from loginStatus, and mutually exclusive. ie: cannot be success | unauthorized AND loading | reloading.

  2. Let the user through (assuming they're auth'd) if they have a refresh token in their localstorage. In first instance, this could feel the same than the interceptor refresh logic, but the main differences are:

  • When the interceptor does the token refresh, there's already data in the screen. On a refresh (F5), we can't display any data simply because we don't have it. We could show "skeletons" though.
  • We'll probably hit a 401 in GET /user-profile if we let the user through as authenticated, like in 1.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions