plotly / plotly/dash

add ability to add custom request headers

Open
#1,329 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

I'm looking for a way to customize the DashRenderer request HTTP headers, mainly for authentication purposes. There's a thread on the community forum that wasn't resolved, but otherwise I don't see any discussion, either on GitHub or on the forum. I was wondering, has there been any progress on this? And if not, would you be willing to accept help and/or help me out creating a PR for this?

It looks to me a reasonably straightforward solution would be to modify the handleServerside callback to look something like this:

function handleServerside(
    hooks: any,
    config: any,
    payload: any
): Promise<any> {
    let rawRequest = mergeDeepRight(config.fetch, {
        method: 'POST',
        headers: getCSRFHeader() as any
    });

    if (hooks.request_pre !== null) {
        hooks.request_pre(payload, rawRequest);
    }

    rawRequest.body = JSON.stringify(payload);
    return fetch(
        `${urlBase(config)}_dash-update-component`,
        rawRequest
    ).then(...)
}

and then to modify the request_pre hook to accept an additional parameter.

Alternatives I can think of:

  • Expose only the headers as an additional parameter to the request_pre hook.
  • Expose the config object to a new (pre-load) hook

What are your thoughts on this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the DashRenderer handleServerside callback and the existing request_pre hook described in the issue. Compare the proposed ways to expose request headers or config, then define a completed design in which callers can customize headers for authenticated requests and the relevant request behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.