I get error ERR_CERT_COMMON_NAME_INVALID when accesing Realm from plain html file

Hi. I don’t have a frontend server. I have created a plain html file that has javascript to connect to a database with this code:

        const app = new Realm.App({ id: xxx' });
        const credentials = Realm.Credentials.emailPassword('xxx@gmail.com', 'xxxx');
        // Authenticate the user
        const user = await app.logIn(credentials);
        // `App.currentUser` updates to match the logged in user
        console.assert(user.id === app.currentUser.id);

I get error ERR_CERT_COMMON_NAME_INVALID.

As there is no real website but an html file running on the browser I have no SSL certificate.

I have tried to host the html file in services like CloudFlare with the same result.

What can I do?

Thanks.

Understanding the xxx is the AppId, is that the actual code with the extra ’ in it? Or is that just a typo here?

Are you attempting to connect to Atlas App Services? Also, it feels like the code is missing .config or perhaps need to use .getApp? The environment is a little unclear so that’s just a guess.

Hi Thanks for answering.

Yes it’s { id: ‘xxx’ });

I am trying to connect to an Atlas database.
I haven’t seen an getApp call in the documentation.

The only missing part was a finall:

    this.db = user.mongoClient('mongodb-atlas').db('xxx');

This code is javascript running on a element.