In the authentication library, when a 401 error occurs, certain default flows (e.g., automatic redirects or error handling) might trigger, which can disrupt your application’s process. To resolve this, I recommend writing a custom authentication middleware to handle 401 errors explicitly. This allows you to control the logic (e.g., token refresh, redirects, or API calls) without relying on the library’s default behavior, ensuring the process remains stable