Everytime I send a request to the api, it returns a CORS error. I think this is a bug.
Access to XMLHttpRequest at 'https://api.mojang.com/user/profiles/<uuid>/names' from origin '<my website>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Linked issues
relates to 1
Comments 3
"Not a bug" - maybe. But this is an issue that can only be resolved with adding one or more response headers at the server. On the other hand you could give a confirmation like "we don't want that the API can be used from scripts that are running in modern browsers".
A workaround for this is to create an endpoint that fetches the API and returns the body
Here is an example i used for my sveltekit site:
export async function get({ params }): Promise<any> { const r = await fetch(`https://api.mojang.com/users/profiles/minecraft/${params.user}`); return { body: await r.body }}
Not a bug