Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bellini's avatar

blocked by CORS error - SOLVED

Hey, i am getting the following errors when i try to use an api with axios:

Access to XMLHttpRequest at 'https://api.coindesk.com/v1/bpi/currentprice.json' from origin 'http://cryptogains.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Uncaught (in promise) Error: Network Error
    at createError (app.js:13874)
    at XMLHttpRequest.handleError (app.js:13758)

I already installed barryvdh package and registered it in the kernel.php file on middleware and the api group routes, but the error persisted. Any idea how i can fix this without using an external chrome extension.

0 likes
3 replies
MThomas's avatar

Most API's don't allow you to connect them from the client side.

You first should fetch the data from the Coindesk API on the server side and then publish them on your own API or push them on to a view.

bellini's avatar

@MTHOMAS - i have used this api on simple html with a view instance before tho.

bellini's avatar

I should add i am using Laragon with Apache, can that be the problem?

Please or to participate in this conversation.