allow changing axios settings

This commit is contained in:
OfficialDakari 2024-10-10 19:45:40 +05:00
parent ab73d68c28
commit a713d6ecae
2 changed files with 2443 additions and 2 deletions

2440
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import axios, { AxiosInstance } from "axios" import axios, { AxiosInstance, CreateAxiosDefaults } from "axios"
import { Cookie, CookieJar } from "tough-cookie" import { Cookie, CookieJar } from "tough-cookie"
import { FE_MUSIC_HOME } from "./constants" import { FE_MUSIC_HOME } from "./constants"
@ -36,7 +36,7 @@ export default class YTMusic {
* Creates an instance of YTMusic * Creates an instance of YTMusic
* Make sure to call initialize() * Make sure to call initialize()
*/ */
public constructor() { public constructor(opts?: CreateAxiosDefaults) {
this.cookiejar = new CookieJar() this.cookiejar = new CookieJar()
this.config = {} this.config = {}
this.client = axios.create({ this.client = axios.create({
@ -47,6 +47,7 @@ export default class YTMusic {
"Accept-Language": "en-US,en;q=0.5", "Accept-Language": "en-US,en;q=0.5",
}, },
withCredentials: true, withCredentials: true,
...opts
}) })
this.client.interceptors.request.use(req => { this.client.interceptors.request.use(req => {