Problem with netlify-identity.js lambda function and fauna-db

hey guys, following problem:
I have created a page with netlify and fauna-db which allows registration. A collection of users in fauna storing the users on clicking the confirmation mail from netlify identity through the identity-signup.js function file. It was working quite fine for that project. now I’ve created a new project, new fauna database, new keys but users are always entered in the old database when registering. Do you know what the problem is? I have also deleted the identity-signup file in the new project and users are still created in the database of another project…

Hi @james015, can you tell us which two sites you are referring to (the original working one and the new one that still connects to the original database instance)? I think that maybe your identityi-signup.js function on the new one might be hardcoded to point to the first db instance.

Hi Dennis, thanks for your reply. This error 's driving me crazy…In the meantime I made a new netlify and also fauna account for testing purposes and deployed a fresh site from a new created repository, created a new database, changed all env variables of course including netlify env (FAUNA_SERVER_KEY) on first deploy, and also .toml file and the problem is still there. On the other hand, all the other functions are working and creating content in the correct database and collection / index. It’s only the problem with the user collection record on signup. If I signup on the new page -> after confirmation link -> user is created into old database of another site. so I don’t think that there is anything hardcoded problem in here…
Here is my identity-signup file:

"use strict"
const faunadb = require("faunadb");
const generator = require('generate-password');

/* configure faunaDB Client with our secret */
const q = faunadb.query
const client = new faunadb.Client({
  secret: process.env.FAUNADB_SERVER_SECRET

/* create a user in FaunaDB that can connect from the browser */
function createUser(userData, password) {
  return client.query(q.Create(q.Collection("users"), {
    credentials : {
      password : password
    data : {
      id :,
      user_metadata : userData.user_metadata

function obtainToken (user, password) {
  console.log("creating FaunaDB token for " + user)
  return client.query(
    q.Login(q.Select("ref", user), { password }))

function handler(event, context, callback) {
  var payload = JSON.parse(event.body);
  var userData = payload.user;

  const password = generator.generate({
      length: 10,
      numbers: true

  createUser(userData, password)
    .then((user) => obtainToken(user, password))
    .then((key) => callback(null, {
      statusCode: 200,
      body: JSON.stringify({
        app_metadata: {
          faunadb_token : key.secret
          // we discard the credential, and can create a new one if we ever need a new token
          // faunadb_credential : password
        } })
    })).catch((e) => {
      callback(null, {
        statusCode: 500,
        body: JSON.stringify({
          error: e
module.exports = {
  handler: handler,
  createUser: createUser,
  obtainToken: obtainToken

That’s a very unusual issue. I’m not really seeing where the issue could be. Could you give me the urls of the working site and the one that is not working correctly so I can take a look?

Hi @james015,

I took a look but unfortunately, I can’t see why this is occurring.

Regarding logs, there is an existing issue with function logs when it is an event-triggered function. To get around this, you can change the name of your function and then set it as the webhook notification here: This should allow the logs to work and should help us troubleshoot further.

I’ve also asked FaunaDB to see if they can help us narrow down the cause of the issue from their end as well.

Thank you for your patience!

Just wanted to ask if you could also provide the email addresses used for each of the databases you mentioned and the name of the database itself. This will be needed to investigate further. Thanks!

hey Dennis, thx for reply
identity-signup.js should be named exactly this way to work properly, otherwise it won’t work, right?
just send you a pm with the db names and used email addresses. thanks

got your dm. I’ll pass it on to faunadb to investigate. I’ll let you know what they find.

Hi James,

Fauna Support checked and it seems like your two sites are using the same key and referring to the same database ID when creating the new user in Fauna. Can you provide specific live urls so I can test to see which lambda function your site is invoking?

Hi, thanks for providing the sites so I can test. I did signed up here: but I see it triggered the function, which is your other site. It seems that your netlify-identity-widget is getting initialized to the same identity endpoint., which I’m not quite sure why. Can you show how you are initializing your identity widget?

You could try to pass an object when you call the init() function like:

  APIUrl: ''; // try setting the correct endpoint here

Let me know if that makes sense.

Hi, initializing identity happened via the identity tab on the netlify site

Hi @james015,

Right, Identity is indeed initialized in the UI. But since you are using the netlify-identity-widget in your code, could you tell me how you are initializing the widget (not the Identity instance in the UI)?