Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting custom headers on separate instances of Servers is misbehaving #1088

Open
Shaptic opened this issue Oct 23, 2024 · 1 comment · May be fixed by #1089
Open

Setting custom headers on separate instances of Servers is misbehaving #1088

Shaptic opened this issue Oct 23, 2024 · 1 comment · May be fixed by #1089
Assignees
Labels

Comments

@Shaptic
Copy link
Contributor

Shaptic commented Oct 23, 2024

What

If you create two instances of a Server (regardless of whether it's for rpc or Horizon) and pass custom headers, the second instance of the server will still have the first instance's custom headers.

In other words,

const s1 = new Server(..., { headers: { "Custom-A": "value" } });
const s2 = new Server(..., { headers: { "Custom-B": "value" } });
s2.someMethod();

invoking someMethod will send both Custom-A and Custom-B headers.

Why

This is occurring because the AxiosClient variable is global shared across all Server instances which inject an interceptor to use the custom headers, so the interceptors are additive.

Known Workarounds

You can refresh the page to get a new AxiosClient instance created and the first construction of a Server will work as intended. You may also be able to work around this by using the noaxios bundle.

@Shaptic Shaptic added the bug label Oct 23, 2024
@Shaptic Shaptic self-assigned this Oct 23, 2024
@Shaptic
Copy link
Contributor Author

Shaptic commented Oct 23, 2024

This is a blocker for the Laboratory unless the noaxios variant fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant