Getting this error while uploading NFT. When clicked on create NFT, it shows axios cors error bad request 400! PLEASE HELP
const projectId = “XXXX”;
const projectSecret = “XXXX”;
const subdomain = “https://nftmarket1012.infura-ipfs.io”;
const authorization = Basic ${Buffer.from(
${projectId}:${projectSecret}).toString("base64")}
;
const client = ipfsHttpClient({
host: “infura-ipfs.io”,
port: 5001,
protocol: “https”,
headers: {
authorization: authorization,
},
});
import {
marketplaceAddress
} from ‘…/config’
import NFTMarketplace from ‘…/artifacts/contracts/NFTMarketplace.sol/NFTMarketplace.json’
export default function CreateItem() {
const [fileUrl, setFileUrl] = useState(null)
const [formInput, updateFormInput] = useState({ price: ‘’, name: ‘’, description: ‘’ })
const router = useRouter()
async function onChange(e) {
const file = e.target.files[0]
try {
const added = await client.add(
file,
{
progress: (prog) => console.log(received: ${prog}
)
}
)
const url = https://nftmarket1012.infura-ipfs.io/${added.path}
setFileUrl(url)
} catch (error) {
console.log('Error uploading file: ', error)
}
}
async function uploadToIPFS() {
const { name, description, price } = formInput
if (!name || !description || !price || !fileUrl) return
/* first, upload to IPFS /
const data = JSON.stringify({
name, description, image: fileUrl
})
try {
const added = await client.add(data)
const url = https://nftmarket1012.infura-ipfs.io/${added.path}
/ after file is uploaded to IPFS, return the URL to use it in the transaction */
return url
} catch (error) {
console.log('Error uploading file: ', error)
}
}