📜  如何从节点应用程序中删除 cors 错误 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:51.343000             🧑  作者: Mango

代码示例1
app.use(function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
    res.setHeader('Access-Control-Allow-Credentials', true);
    next();
});