farshed/genius-lyrics-api

Issue: Missing CORS ('Access-Control-Allow-Origin') on deployed website.

robo311 opened this issue · 3 comments

I thought its just issue when I was developing the website using this library, so I used the addon to bypass the CORS rules. But I deployed it via firebase but I'm having the same issue. Is there any solution to that?

Please and thank you.

same issue

I mention in the README that it's only meant to be used in non-browser environments. This is because browsers will block any request that does not satisfy the CORS policy. In this case, the browsers only allow those requests to genius.com that originate from genius.com itself. The only solution is to fetch the lyrics server-side.

const proxyUrl = 'https://thingproxy.freeboard.io/fetch/';

You can use a proxyurl instead of creating a proxy on the server side.

const response = await axios.get(`${proxyUrl}${link}`);

for example, this should work, and its supposed to clear any CORS error
getLyrics((`${proxyUrl}${link}