Blockfrost API 403 Error in React Node JS app
I’m trying to get info about the latest block in my React Node JS app using Blockfrost and I’m running into an error:
GET https://cors-anywhere.herokuapp.com/https://cardano-mainnet.blockfrost.io/api/blocks/latest 403 (Forbidden)
Why is this happening? Any potential solutions are much appreciated!
Here’s my code:
useEffect(() => {
fetch(
'https://cors-anywhere.herokuapp.com/https://cardano-mainnet.blockfrost.io/api/blocks/latest',
{
contentType: "application/json",
headers: {
project_id: PROJECT_ID
},
method: 'GET'
}
)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
return response.json()
})
.then(data => {
console.log(data)
})
.catch(error => {
console.error(error)
})
}, [])
Read more here: Source link