3

I am testing with IPFS and http but I have an error as follows:

App.js:239 ipfs add error DOMException: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV).

I have this code -

var zstr = 'hello world from Zillerium2'
   this.IpfsAPI.add(new Buffer(zstr), function (err, res){
          console.log("hello");
          if(err || !res) return console.error("ipfs add error", err, res);
          else{
            console.log("no issue");
            console.log(res);
            res.forEach(function(text) {
                   console.log('successfully stored', text.hash);
                 //  console.log('successfully stored', text.path);
                 //  display(file.Hash);
                    var textaddress=text.hash;
                    console.log(textaddress);
            });
          }
        });

I understand from the IPFS forum that https is not needed for API calls, so is there a config to set or something to rid the system of this error?

2

I have discovered that https is not required for access.

This brings back results showing no https was needed -

curl -H "Origin: http://jenbil.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: X-Requested-With" \
--verbose \
http://162.243.237.41:5001/api/v0/swarm/peers; echo

Also testing with Chrome and the network tab you may see the actual status of calls and that no https was needed.

You do have to make sure ipfs cors are set correctly, and confirm using

ipfs config show

which gives me -

root@ubuntu-2gb-nyc2-01:/home/zipfs/test# ipfs config show
{
  "API": {
    "HTTPHeaders": {
      "Access-Control-Allow-Credentials": [
        "true"
      ],
      "Access-Control-Allow-Methods": [
        "PUT",
        "POST",
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    }
  },
  "Addresses": {
    "API": "/ip4/0.0.0.0/tcp/5001",
    "Gateway": "/ip4/0.0.0.0/tcp/8180",
   "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001"
    ]
  },
0

to get rid of this error :

Only secure origins are allowed

use these two commands:

ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.