Administration Login fails, is something wrong with my Function?

Hello, I try to use the Realm Administration API and this is the function for getting the token.

async function cloudLogin() {
    const response = await fetch(
        method: "POST",
        headers: {
          "Access-Control-Allow-Origin": "*",
          "Content-Type": "application/json",
        body: JSON.stringify({
          username: "<Public API Key>",
          apiKey: "<Private API Key>",
    const json = await response.json();

The error I get is

Access to fetch at '' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

As the message suggests to add ‘no-cors’ I also tried this but then I get this

Uncaught (in promise) SyntaxError: Unexpected end of input
this line > const json = await response.json();

Doing a curl works but with fetch no chance, does anyone see the issue here? I allowed my current IP Address and I do the fetch from localhost:3000


I solved this by moving the function from my client-side react app to a realm function, I think this endpoint doesn’t like to be called from the browser.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.