0

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)
  })

}, [])

1 Answer 1

1

Your URL appears to be incorrect:

https://cors-anywhere.herokuapp.com/https://cardano-mainnet.blockfrost.io/api/blocks/latest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.