Ajax cross-domain cannot get http error code

as above.
when calling a cross-domain interface, if the interface returns an error code such as 500, the front end cannot obtain the response error code (of course, 200 code is able to obtain information normally).
it seems impossible to solve it at the front-end level. How should the server make changes so that the front-end can get the error message normally?

ps: cannot be returned in this way: background status code 200, and then put {code: 500}

in the data.
Sep.03,2021

ajax error callback

axios.get('/user/12345')
  .catch(function (error) {
    if (error.response) {
      //  2xx 
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    } else {
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);
    }
    console.log(error.config);
  });
Menu