How can i use Dedicated gateway for ipfs js Plz help

now i am try to make website for minting and trade NFT.

but now i can not use dedicated gateway.

This is the process to get the iPFS URL by sending the selected IMAGE to Infura.

but now it shows error becoz public infura doesn’t work .

I used public infura like this

	const IPFS_URL = "";
	const IPFS_API_URL = "";
	const ipfs = window.IpfsApi(IPFS_API_URL, "5001", { protocol: "https" }); // Connect to IPFS

	$("#btn_uploadfile").on("click", function () {
		if ($("#uploadfile").val() == "") {
			alert("selcet image");

		var reader = new FileReader();
		reader.onloadend = function () {
			//console.log("reader.result" + reader.result);
			var buf = buffer.Buffer(reader.result); // Convert data into buffer
			ipfs.files.add(buf, (err, result) => {
				// Upload buffer to IPFS
				if (err) {

				var hash_img_url = IPFS_URL + result[0].hash;

				//console.log(`Url --> ${hash_img_url}`);
				$("#ipfs_file_url").attr("href", hash_img_url);

		reader.readAsArrayBuffer($("input#uploadfile")[0].files[0]); // Read Provided File

now public infura is not working so i made dedicated gateway like this

but i don’t know how it use and where should i put this.

Plz help me

Hey @Mr_Tai to access your files on the dedicated getaway your URL should look as follows: → where CID is the CID return after pinning/uploading a file.

1 Like

Thank you i tryed it . but after it they show me that error

POST 401 (Unauthorized)

now my code like this .
after upload button infura works but return 401 error

Thank you for your Help.

I solved problem !!. :slight_smile:

@Mr_Tai Apologies for the late reply!
I’m glad that you have resolved the issue.

Just to note, you were missing authentication in your buf; that should include project id and project secret to authenticate requests!

How did you solve the problem?