Auth0 Home Blog Docs

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource



I’m having troubles in calling a login API from a local machine.
I’ve read through answers here and also search thew web, but I couldn’t find the reason login doesn’t work for me.
I can sign up users, but when I try to log in a previously created user I get the following error on the browser: "Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource"
I am not using a hosted login page, instead I render my own and call the Auth0 api using ‘auth-js’ npm library (version 9.1.3).
This is the source code I’m using for signup (which works fine) and for the login (which fails):
Can anyone help me here?

export default class AuthService extends EventEmitter {
    constructor(clientId, domain) {
        // Configure Auth0
        this.auth0 = new auth0.WebAuth({
            clientID: clientId,
            domain: domain,
            responseType: 'token id_token',
            redirectUri: `${window.location.origin}/`
        this.login = this.login.bind(this);
        this.signup = this.signup.bind(this);
        this.loginWithGoogle = this.loginWithGoogle.bind(this);
    login(username, password) {
            realm: 'Username-Password-Authentication',
        }, (err, authResult) => {
            if (err) {
                alert('Error: ' + err.description);
            if (authResult && authResult.idToken && authResult.accessToken) {
                this.setToken(authResult.accessToken, authResult.idToken);
                window.location = window.location.origin; //redirect to main page
    signup(email, password) {
            connection: 'Username-Password-Authentication',
        }, function (err) {
            if (err) {
                alert('Error: ' + err.description)