Skip to content

Cube react client incompatible with React 19?Β #9797

@tomdarmon-appstack

Description

@tomdarmon-appstack

Bug: useCubeQuery fails with 403 error – Authorization header is undefined

Description

This issue occurs when running the app using npm run start (i.e., in production mode).

When using @cubejs-client/react versions between 0.39.0 and 1.3.39 on React 19 with Next.js, the useCubeQuery hook fails with a 403 error due to a missing authorization header (Authorization: undefined). However, accessing the cubeApi object directly via useContext(CubeContext) works as expected and contains the cubeApi correctly initalized (with correct url and token).

Works

import { CubeContext } from "@cubejs-client/react";
const contextValue = useContext(CubeContext);
const cubeApi = contextValue.cubeApi;
console.log(cubeApi) // --> Contains a valid token and url  

Fails

import { useCubeQuery } from "@cubejs-client/react";
const { resultSet } = useCubeQuery(...); // β†’ 403 error, auth header is undefined

Steps to Reproduce

  • Use React 19.1.0 with Next.js 15.4
  • Wrap components with CubeProvider and attempt to use useCubeQuery
  • Run the app using npm run build and then npm run start (in dev mode it works)
  • Observe a 403 response due to a missing Authorization header

Metadata

Metadata

Assignees

No one assigned

    Labels

    client:reactIssues relating to the React client SDKquestionThe issue is a question. Please use Stack Overflow for questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions