https://api.myetherwallet.com/eth

时间:2019-05-30 10:41:30

标签: node.js ethereum

我想部署Myetherwallet github项目(https://github.com/MyEtherWallet/MyEtherWallet )。

项目正在成功构建,但是在部署其给出错误时 因为它在网站上,它正在提供网络错误。

下面是错误日志:

CORS policy Error

1 个答案:

答案 0 :(得分:0)

这是任何REST API中阻止所有跨域传入请求的理想行为。要禁用它,您可以使用类似的逻辑来允许所有传入请求。

server.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*'); // * can be replaced with any domain name
    res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT, PATCH, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
    next();
});

同样可以使用cors软件包https://www.npmjs.com/package/cors来实现