Solution for cors error in fetch() or XMLHttpRequest()


I like to use Visual Studio Code to further practice the code learned in the Codecademy courses.

So I am practicing the fetch() requests to Datamuse (GET) and Rebrandly (POST) locally.

I am running the code in a live server.

But when tryig to make the fetch() request, it fails and I get the CORS error in the console because the request comes from my localhost.

Is there a simple solution for this?

Many thanks in advance for your reply.

1 Like


When entering a valid url all works fine.

(was typing random text in the input field for testing the request and this caused the request to fail)

Sorry to bother