How to Redirect to Login Page for 401 Errors in Tutor Redwood Open edX Studio API

I’m using Tutor Redwood (Open edX) and encountering a 401 Unauthorized error when accessing certain Studio API endpoints, such as

1. /api/contentstore/v1/home
2. api/contentstore/v1/course_index/{course_id}
3. api/courses/v1/quality/{course_id}/?exclude_graded=true&all=true
4. api/courses/v1/validation/{course_id}/?graded_only=true&validate_oras=true&all=true
5. api/contentstore/v1/help_urls

The error seems to be due to authentication issues.

Instead of returning a 401 response, I would like to redirect unauthenticated users to the login page.

Has anyone implemented a solution for redirecting users to the login page when accessing unauthenticated Studio APIs? Any suggestions or best practices would be greatly appreciated.