解决添加authorization 请求头跨域问题
在做身份认证的时候前端请求头上增加authorization 属性后报以下错误:
Access to XMLHttpRequest at 'http://127.0.0.1:500/api/login' from origin 'http://127.0.0.1:5501' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
解决方案:在服务端允许跨域的header类型里加上authorization
res.header("Access-Control-Allow-Headers",["content-type",'Authorization']);