“No Access-Control-Allow-Origin” Error – Cors Plugin

“No Access-Control-Allow-Origin” Error – Cors Plugin

I have been developing a reactjs application that calls a spotify-api that return some information on music artist. I got this error “No Access-Control-Allow-Origin Error” as below

AllowNoOrigin01

After doing some research I found out that Javascript is limited when making ajax / fetch requests outside of the current domain.

  • Ex 1: your domain is example.com and you want to make a request to test.com => you cannot.
  • Ex 2: your domain is example.com and you want to make a request to inner.example.com => you cannot.
  • Ex 3: your domain is example.com:80 and you want to make a request to example.com:81 => you cannot
  • EX 4: your domain is example.com and you want to make a request to example.com => you can.

Javascript is limited by the “same origin policy” for security reasons so that a malicious script cannot contact a remote server and send sensitive data.

To fix this error I had to install Cross-Origin Resource Sharing (CORS) client plugin on my chrome browser.

AllowNoOrigin02

The results, I was able to call Web Spotift Api and return the information on that music artist

AllowNoOrigin03

Others way of fixing this error is to install Cors also on the server end. Below is video from utube on resolving this on C# – https://www.youtube.com/watch?v=uDy_cvf4nDg

 

Leave a Reply

Your email address will not be published. Required fields are marked *