I am having a problem with fetching profile data from Trovo API.
Access to fetch at 'https://open-api.trovo.live/openplatform/channels/id' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
In the documentation of the API says:
If you are making API calls from the client side, you may come across CORS issues. Your domain needs to be whitelisted in Trovo in order to do CORS calls.
In addition, please add origin in the header when you are making cross-site calls.
I am getting this error on production too, where I am using my registered domain.
const fetchProfile = async () => {
const ress = await fetch(
"https://open-api.trovo.live/openplatform/channels/id",
{
method: "POST",
headers: {
Accept: "application/json",
"Client-ID": `${process.env.TROVO_CLIENT_ID}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: '{"username":"test"}',
}
).then((res) => res.json());