Error: unauthorized 401

hi folks, how are you? I’m new to Fauna and it’s giving an error when I create a new user in my collection called ‘tutors’.

first i created a file to declare the Client, with the FAUNADB_KEY on my .env.local


import { Client } from 'faunadb';

export const fauna = new Client({
  secret: process.env.FAUNADB_KEY,
  domain: ''

and then i tried to create my first document:

const handleCreateUser: SubmitHandler<CreateTutorFormData> = async data => {
    await fauna.query(
          data: {
            cpf: data.cpf,
            address: data.address,
      .then(res => res)
      .catch(err => console.error('Error: ', err.message));


on the console, shows me:

Captura de Tela 2021-10-05 às 20.06.40

obs: the stack that i’m using is: TypeScript, ReactJS, NextJS.

anyone can help me?

Welcome @eduardomarr!

One thing to check is that you’re using the correct endpoint for your database. is used for the Classic region group. If you’re using either the US or EU ones you would want to change that to either or, respectively.


Hi @eduardomarr,

Are you still having difficulty or did you get your auth working?