express支持跨域解决方案

express支持跨域解决方案

在网上找了很多方法,只有如下方法可用:

app.all('*', function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    res.header('Access-Control-Allow-Methods', '*');
    res.header('Content-Type', 'application/json;charset=utf-8');
    next();
});

猜你喜欢

转载自www.cnblogs.com/tdd-qdkfgcs/p/11253448.html
今日推荐