Auth0 Home Blog Docs

Ngrok Custom Database connection via Login Action Script

auth0

#1

I’m trying to test my login action script for migrating users on a localDB via ngrok, but auth0 seems to be prepending port 3306 for me. Is there a way to stop this from automatically being prepended to my configuration.DB_HOST? So when I test the connection via the “try” button, it trys to reach out to whatever I have stored in configuration.MYSQL_HOST, which is my ngrok url pointing to my local tcp connection, and somehow the action script prepends the 3306. So the end result of what it trys to connect to, looks something like https://48e198bb.ngrok.io:3306 but https://48e198bb.ngrok.io is already pointing to that port on my computer, so auth0 reads it as :3306:3306

Here’s my login action script:

  console.log("starting script");
  var connection = mysql({
    host: configuration.MYSQL_HOST,
    user: configuration.MYSQL_USER,
    password: configuration.MYSQL_PASSWORD,
    database: configuration.MYSQL_DB
  });

  connection.connect();

  var query = "SELECT id, email, password " +
    "FROM users WHERE email = ?";

  connection.query(query, [email], function (err, results) {
    if (err) return callback(err);
    if (results.length === 0) return callback(new WrongUsernameOrPasswordError(email));
    var user = results[0];

    bcrypt.compare(password, user.password, function (err, isValid) {
      if (err) {
        callback(err);
      } else if (!isValid) {
        callback(new WrongUsernameOrPasswordError(email));
      } else {
        callback(null, {
          id: user.id.toString(),
          email: user.email
        });
      }
    });

  });
}```

#3

Hey there @MrBoutte! I am currently looking into this with our support team but in the mean time will you DM me your tenant name when you get a chance? Thanks!


#4

After talking with our support team, they recommend trying setting the port value in mysql options to 80 or 443. Please let me know if you have any questions!


#5

I wanted to follow up with you this morning and see if you had any additional questions on this front @MrBoutte? Thanks!