0

I have a ubuntu server having cloudflare enabled in it. I have set up the nginx for reverse proxy, I have defined the ports and done IPFS setup.

While adding the file on the server I am getting the error that says: Unexpected token < in JSON at position 0

I am creating a buffer of a file and adding the data using ipfs.files.add function.
Here is the code snippet:

let testBuffer = new Buffer(testFile); 
ipfs.files.add(testBuffer, function (err, file) { 
  if (err) { 
        console.log(err); 
        res.send(responseGenerator.getResponse(500, "Failed to process your request!!!", [])); 
  }
  console.log(file) 
}

Kindly help with the solution. Thanks.

Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29
Danish
  • 43
  • 5
  • Can you post the json that is causing the problem? – Stephan Hogenboom Aug 20 '19 at 09:08
  • I am creating a buffer of a file and adding the data using ipfs.files.add function. Here is the code snippet: let testBuffer = new Buffer(testFile); ipfs.files.add(testBuffer, function (err, file) { if (err) { console.log(err); res.send(responseGenerator.getResponse(500, "Failed to process your request!!!", [])); } console.log(file) – Danish Aug 20 '19 at 09:24
  • I am following the below tutorial https://hackernoon.com/public-ipfs-node-behind-nginx-reverse-proxy-5682747f174b – Danish Aug 20 '19 at 09:48
  • So what is in the testFile? Looks like a parsing error – Stephan Hogenboom Aug 20 '19 at 10:05
  • without nginx can we use https for ipfs? – Danish Aug 20 '19 at 10:06

0 Answers0