lichess-org / api

Lichess API documentation and examples
https://lichess.org/api
GNU Affero General Public License v3.0
417 stars 140 forks source link

CORS error in "export one study chapter" API / JS in browser #237

Closed dragunovartem99 closed 1 year ago

dragunovartem99 commented 1 year ago

Help me, please! Am I doing it wrong?

async function getChapterPGN() {
    const response = await fetch("https://lichess.org/study/***/***.pgn");
    const data = await response.text();
    // Then I do something with data
}

I tried to add "no-cors" mode, bearer token with study permissions, tried to write "accept" with "application/x-chess-pgn" in headers, but nothing worked.

But when I suppressed this issue with https://mybrowseraddon.com/access-control-allow-origin.html - everything worked perfectly!

Was this behavior for Study APIs made by design? Or I am doing something wrong?

ornicar commented 1 year ago

only endpoints starting with /api/ can be used from a browser. Please create an issue on https://github.com/lichess-org/lila requesting one for this use case.

dragunovartem99 commented 1 year ago

Thank you!