The returned error.response object cannot be received when axios is cross-domain.

problem description

In the case of

axios cross-domain, none of the return codes can be received except 200.

the environmental background of the problems and what methods you have tried

use ivew-admin as the background management system, and act as the interceptor in axios. When the return code is 401, the authentication of re-login is carried out, but it is found that in the case of cross-domain, if the background returns 401, the response object returned cannot be received in the front-end code
r

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

instance.interceptors.response.use (res = > {

)
  this.distroy(url)
  const { data, status } = res
  alert("status=>" + status)
  if (status === "401") {
    ssoLogin()
  }
  return { data, status }
}, error => {
  for (var key in error) {
    console.log(key, error[key])
  }

what result do you expect? What is the error message actually seen?

some people have encountered this problem on the Internet, but they have not given a specific solution. Please give us a move.

Nov.19,2021

if you are using webpack-dev-server, you can set proxyTable, as a layer of proxy


then can not receive catch


how to solve this problem?

Menu