FaunaDB GraphQL API returning "Invalid database secret"

Viewed 274

I have been trying to connect to FaunaDB's GraphQL API in Gatsby functions, but for an unknown reason, it doesn't recognize the database secret. It did work before. I have checked multiple times that the secret is all correct-

get-all-likes.ts

export default async function (
  _req: GatsbyFunctionRequest,
  res: GatsbyFunctionResponse
) {
  const { data, errors } = await query(QUERY_STRING);

  if (errors) {
    return res.status(500).json(errors);
  }

  return res.status(200).json({ allLikes: data.allLikes.data });
}

query.ts

export default async function (query: String, variables?: any) {
  const result = await axios({
    url: 'https://graphql.fauna.com/graphql',
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.FAUNA_SECRET}`,
    },
    data: {
      query,
      variables,
    },
  });

I have also tried to regenerate the secret but that also returns the same error message but I can't find what could be wrong here-

enter image description here

1 Answers

Along the lines of what @AndersKitson points out - if you're using an EU region group, you'll need to update your endpoint to graphql.eu.fauna.com/graphql

Related