My solution was to return 401 in ensureAuthenticated function and handles the 401 in React.
ensureAuthenticated