Logging Out Users on 401 Error in Next.js with auth.js
Scenario:
While fetching data on the server side, I use a custom wrapper function based on fetch as a centralized API handler for my application. When the server returns a 401 (Unauthorized) error, I expected to be able to log the user out (or take similar actions), just like how Axios interceptors handle such cases.