ipfsHttpClient giving Invalid Project ID but only in production build

Hey guys,

I have the ipfsHttpClient set up in the normal way as specified in the docs

const client = ipfsHttpClient({
host: “ipfs.infura.io”,
port: 5001,
protocol: “https”,
headers: {
authorization: auth,
},
});

It works fine on my local host and the pinned files show up in my dashboard straight away but when I push the build to production i get:

POST https://ipfs.infura.io:5001/api/v0/add?stream-channels=true&pin=true&progress=false 401 (Unauthorized)
Uncaught (in promise) HTTPError: basic auth failure: invalid project id or project secret

Does anyone know what i am doing wrong?

Thanks

1 Like

Hey :wave: @Will_Rankin and welcome to the Infura community!

Would you be able to share with us how you set up auth?
Is your production set up any different?

Please refer to the below:

1 Like

i tried, but always same issue
basic auth failure: invalid project id or project secret

tried with postman, but never solved.
very disappointed with ipfs with infura

1 Like

The problem is solved!!!

In the infura site:
Step 1. Create IPFS project with card info
Step 2. replace the following code with your old code

const projectId = ‘2E8Kps3Xij…’; //(Step 3. Place the project id from your infura project)
const projectSecret = ‘b222afc94…’; //(Step 4. Place the project_secrect from your infura project)

const auth = 'Basic ’ + Buffer.from(projectId + ‘:’ + projectSecret).toString(‘base64’);

const ipfsClient = require(‘ipfs-http-client’)
const ipfs = ipfsClient.create({
host: “ipfs.infura.io”,
port: 5001,
protocol: “https”,
apiPath: “/api/v0”,
headers: {
authorization: auth,
},
});

Step 5. Save and npm start

1 Like