lichess-org/api

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

dragunovartem99 opened this issue · 2 comments

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?

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.

Thank you!