Skip to content

Support for setting headers for CubejsApi (cubejs-client-core) #241

@ferrants

Description

@ferrants

Is your feature request related to a problem? Please describe.
I'm trying to integrate some testing, but this would be a problem with a front-end integrating as well. I want to set multiple headers to flow through to the USER_CONTEXT, but the client doesn't handle passing in explicit headers.

Describe the solution you'd like
Either defining in the api:

const cubejsApi = cubejs(
    process.env.supersecret,
    {
        apiUrl: 'http://localhost:4000/cubejs-api/v1',
        headers: {'user-id': 1}
    }
)

or define as part of the options for the load/sql operations:

cubejs_api.load({
        measures: ['SovSearchResultRedshiftDaily.count'],
        timeDimensions: [],
  },
  {
    'user-id': 1
  }
)

Describe alternatives you've considered
I can construct the query directly and not use the CubejsApi. @paveltiunov suggested:

As a workaround you can override HttpTransport though.

It's probably good to support this more easily and document around it.

Additional context
I don’t see anything about headers here
https://cube.dev/docs/@cubejs-client-core#cubejs-api
except maybe the options, which doesn’t appear to be documented and I don’t see anything about headers here:
https://github.com/cube-js/cube.js/blob/master/packages/cubejs-client-core/src/index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions