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

User-specified headers aren't being passed to Axios #697

Closed
SuperSonicHub1 opened this issue Nov 25, 2022 · 2 comments · Fixed by #703
Closed

User-specified headers aren't being passed to Axios #697

SuperSonicHub1 opened this issue Nov 25, 2022 · 2 comments · Fixed by #703
Labels
bug Something isn't working released

Comments

@SuperSonicHub1
Copy link
Contributor

export class HttpAxiosImpl extends BaseHttp implements Http {
private readonly axios: AxiosInstance;
constructor(readonly config: MastoConfig, readonly serializer: Serializer) {
super();
this.axios = axios.create({
baseURL: config.url,
headers: this.createHeader(),
proxy: config.proxy,
timeout: config.timeout,

import { login } from "masto"

const instance = await login({
	url: "https://pony.social/",
	headers: {
		'User-Agent': 'this should show up'
	}
})
console.log(instance.config)
console.log(instance.http.createHeader())
{
  url: 'https://pony.social/',
  headers: { 'User-Agent': 'this should show up' }
}
{ 'Content-Type': 'application/json' }

A fix should be as simple as:

 export class HttpAxiosImpl extends BaseHttp implements Http { 
   private readonly axios: AxiosInstance; 
  
   constructor(readonly config: MastoConfig, readonly serializer: Serializer) { 
     super(); 
  
     this.axios = axios.create({ 
       baseURL: config.url, 
       headers: this.createHeader(config.headers), 
       proxy: config.proxy, 
       timeout: config.timeout,

If you want me to, I can send a pull.

@neet neet added the bug Something isn't working label Nov 25, 2022
@neet
Copy link
Owner

neet commented Nov 25, 2022

@SuperSonicHub1 Looks great. I'd love to merge it if you send me a PR 👍

SuperSonicHub1 added a commit to SuperSonicHub1/masto.js that referenced this issue Nov 25, 2022
SuperSonicHub1 added a commit to SuperSonicHub1/masto.js that referenced this issue Nov 25, 2022
@neet neet closed this as completed in #703 Nov 25, 2022
github-actions bot pushed a commit that referenced this issue Nov 26, 2022
## [4.6.9](v4.6.8...v4.6.9) (2022-11-26)

### Bug Fixes

* Actually send user-specified headers in `HttpAxiosImpl` ([b602fe4](b602fe4)), closes [#697](#697)
* Encode URI components in serializer ([8a2be08](8a2be08))
* **fetch:** Normalize header to be lowercase ([f7fce11](f7fce11))
* Fix failing test in [#702](#702) ([a2a4c26](a2a4c26))
* read next link from response ([68c71bd](68c71bd))
* Set `Paginator.nextParams` to an empty object after first request ([4ce57a6](4ce57a6)), closes [#698](#698)
* Unmark `DefaultPaginationParams.{maxId, sinceId}` as internal parameters ([257359e](257359e)), closes [#698](#698)
* Update Notification.type types ([#706](#706)) ([50c5c5c](50c5c5c))
@github-actions
Copy link

🎉 This issue has been resolved in version 4.6.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants