Node solves the interface cross-domain problem

cross domain

What is cross domain?

node as the backend to solve cross-domain problems

If the following three types are requested

  • text/plain
  • multipart/form-data
  • application/x-www-form-urlencoded

Ordinary resource requests can be set in node

//允许所有的所有的http访问
Access-Control-Allow-Origin: *
//指定http域名xxxxx访问
Access-Control-Allow-Origin: http://xxxxx

If the request is of the following type (requires preflight request)

  • application/xxxxx

Ordinary resource request + request header can be set in node

//允许所有的所有的http访问
Access-Control-Allow-Origin: *
//指定http域名xxxxx访问
Access-Control-Allow-Origin: http://xxxxx
//附带身份凭证的请求
//Access-Control-Allow-Credentials: true
//头部设置
Access-Control-Request-Headers: Content-Type

Guess you like

Origin blog.csdn.net/weixin_41891519/article/details/120775193