IPFS Dapp项目POST请求被禁止403

时间:2020-07-31 19:19:50

标签: javascript ipfs decentralized-applications

IPFS配置:

 Gateway": {
            "APICommands": [],
            "HTTPHeaders": {
                "Access-Control-Allow-Headers": [
                    "X-Requested-With",
                    "Range",
                    "User-Agent"
                ],
                "Access-Control-Allow-Methods": [
                    "PUT",
                    "GET",
                    "POST"
                ],
                "Access-Control-Allow-Origin": [
                    "*"
                ]
            },
            "NoDNSLink": false,
            "NoFetch": false,
            "PathPrefixes": [],
            "PublicGateways": null,
            "RootRedirect": "",
            "Writable": false
        }

这是我要创建的功能:

onDrop = async (file) => {
    try {
      const {contract, accounts} = this.state;
      const stream = fileReaderPullStream(file);
      const result = await ipfs.add(stream);
      debugger
    } catch (error) {
      console.log(error);
    }
  };

The error

现在我也遇到此错误:

SyntaxError: Unexpected number in JSON at position 4
    at Object.parse (<anonymous>)
    at stream-to-json-value.js:27
    at stream-to-value.js:12
    at ConcatStream.<anonymous> (index.js:41)
    at ConcatStream.emit (events.js:139)
    at finishMaybe (_stream_writable.js:613)
    at afterWrite (_stream_writable.js:470)
    at afterTick (index.js:48)
    at Item.push../node_modules/process/browser.js.Item.run (browser.js:167)
    at drainQueue (browser.js:131)

我的IPFS守护程序运行良好,我可以通过其桌面应用程序上传文件。我只是无法通过API做到这一点。 谢谢。

0 个答案:

没有答案