langgenius/dify · error · Error

The Console API client requires an authenticated CSRF token.

Error message

The Console API client requires an authenticated CSRF token.

What it means

Error "The Console API client requires an authenticated CSRF token." thrown in langgenius/dify.

Source

Thrown at e2e/support/api/console-client.ts:40

}

const getCsrfToken = async (requestContext: ConsoleRequestContext) => {
  const state = await requestContext.storageState()
  return state.cookies.find((cookie) => cookie.name.endsWith('csrf_token'))?.value
}

export function createConsoleClient({
  apiBaseURL = apiURL,
  requestContext,
  requireCsrfToken = true,
}: CreateConsoleClientOptions): ConsoleClient {
  const link = new OpenAPILink<ConsoleClientContext>(consoleRouterContract, {
    fetch: createPlaywrightFetch(requestContext),
    headers: async () => {
      const headers = new Headers({ Accept: 'application/json' })
      const csrfToken = await getCsrfToken(requestContext)
      if (!csrfToken && requireCsrfToken)
        throw new Error('The Console API client requires an authenticated CSRF token.')
      if (csrfToken) headers.set('X-CSRF-Token', csrfToken)
      return headers
    },
    plugins: [
      new RequestValidationPlugin<ConsoleClientContext>(consoleRouterContract),
      new ResponseValidationPlugin<ConsoleClientContext>(consoleRouterContract),
    ],
    url: new URL('/console/api/', apiBaseURL).toString(),
  })

  return createORPCClient<ConsoleClient>(link)
}

View on GitHub (pinned to ef8544b173)

When it happens

Trigger: Thrown at e2e/support/api/console-client.ts:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/c152a85e42ec9e62. Report an issue: GitHub.