Nodejs解决所有跨域请求
app.use(function(req, res, next) { res.setHeader(‘Access-Control-Allow-Origin‘, ‘*‘); res.setHeader(‘Access-Control-Allow-Methods‘, ‘GET, POST‘); res.setHeader(‘Access-Control-Allow-Headers‘, ‘X-Requested-With,content-type, Authorization‘); next(); });
时间: 2024-10-11 13:40:26