可以使服务器跨域

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
app.all("*",function(req,res,next){
//设置允许跨域的域名,*代表允许任意域名跨域
res.header("Access-Control-Allow-Origin",req.headers.origin||'*');
//允许的header类型
res.header("Access-Control-Allow-Headers","Content-Type,Authorization,X-Requested-With");
// //跨域允许的请求方式
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
// 可以带cookies
res.header("Access-Control-Allow-Credentials",true);
if(req.method=='OPTIONS'){
res.sendStatus(200);
}else{
next();
}
})
更新于

请我喝[茶]~( ̄▽ ̄)~*

CQ 微信支付

微信支付

CQ 支付宝

支付宝

CQ 贝宝

贝宝