An error occurred when fetching client data for Lock: https://

Hi everyone,

I’m using Auth0-lock to create an authentication dialog.I want to create an auth-lock object in a NodeJS file.When I used :

const {Auth0Lock} = require('auth0-lock');

var lock = new Auth0Lock( MyClientId, MyDomain);

lock.show();

in my NodeJS file, I got the following error:

C:\Users.…\node_modules\auth0-lock\lib\utils\url_utils.js:6
var parser = global.document.createElement(‘a’);
^
TypeError: Cannot read property ‘createElement’ of undefined

I defined a virtual dom element for it, using jsdom as follow:

const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM('<!DOCTYPE html><html><body.....</body></html>');

global.window = dom.window;
global.document = dom.window.document;
global.location = dom.window.document.location;

By this, the above error was fixed, but I got another error without showing me the auth0-lock authentication dialog.It is:

Error: An error occurred when fetching client data for Lock: https://cdn.auth0.com/client/[MyClientId].js

Searches showed me this error indicates that Lock could not connect to the Auth0 CDN to fetch client. But when I uses auth0 cdn link and create auth-lock dialog in a html file using script as follow:

<script src="https://cdn.auth0.com/js/lock/10.23.1/lock.min.js"></script>
<script>
var lock = new Auth0Lock( MyClientId, MyDomain);
lock.show();
</script>

it worked with the exact same “MyClientId” and showed me the dialog.

Would you please help me to fix this problem and display the dialog in my NodeJS file?

Thanks

Hey @we.are.mankind

As it has been more than a few months since this topic was opened and there has been no reply or further information provided from the community as to the existence of the issue we would like to check if you are still facing the described challenge?

We are more than happy to assist in any way! If the issue is still out there please let us know so we can create a new thread for better visibility, otherwise we’ll close this one in week’s time.

Thank you!

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