Hello, I have a problem with CORS and I think this is right community to get help.
When I use this code:
import { LemmyHttp } from 'lemmy-js-client';
const client = new LemmyHttp('https://lemmy.ml');
const { posts } = await client.getPosts({
limit: 10,
page: 1
});
to get posts from lemmy.ml (using lemmy-js-client), I get:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://lemmy.ml/api/v3/post/list?limit=10&page=1. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400.
I have tried to add header like this:
const client = new LemmyHttp('https://lemmy.ml', {
headers: {
'Access-Control-Allow-Origin': '*'
}
});
but result is the same.
Can someone help me with this?
Thanks, I’ll watch it