"State not found" error

I'm trying to sign in using apple, but I'm getting this error:
Error Code: state_not_found


According to this code it tries to get the state from the body of the request (in case if it is POST).

The thing is I console.loged body and it has the state parameter. I'm using fastify and the following code to convert fastify request to regular one:
const body = request.body ? JSON.stringify(request.body) : undefined;

console.log('body', body);
// { state: 'AAA', code: 'BBB', id_token: 'CCC' }

const req = new Request(url.toString(), {
  method: request.method,
  headers,
  body,
});
GitHub
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Was this page helpful?