zS1L3NT / ts-npm-ytmusic-api

A type-safe and basic YouTube Music API wrapper
https://npmjs.com/package/ytmusic-api
GNU General Public License v3.0
81 stars 17 forks source link

[BUG]: Cookie not in this host's domain. Cookie: www.youtube.com Request: music.youtube.com #28

Closed SAROND-DEV closed 3 months ago

SAROND-DEV commented 9 months ago

Please describe the current behaviour of the code.

When running the method setCookieSync, i getting an error

error: Cookie not in this host's domain. Cookie:www.youtube.com Request:music.youtube.com
      at setCookie (/mnt/c/Users/PC/Desktop/projects/ts-npm-ytmusic-api/node_modules/tough-cookie/lib/cookie.js:1194:15)
      at /mnt/c/Users/PC/Desktop/projects/ts-npm-ytmusic-api/node_modules/universalify/index.js:5:64
      at /mnt/c/Users/PC/Desktop/projects/ts-npm-ytmusic-api/node_modules/tough-cookie/lib/cookie.js:1726:5
      at /mnt/c/Users/PC/Desktop/projects/ts-npm-ytmusic-api/src/YTMusic.ts:73:6
      at processTicksAndRejections (:61:77)

Please describe the expected behaviour of the code.

Successful run methods

What are the steps to reproduce the error?

Try

const ytm = new YTMusic();
await ytm.initialize();

Additional Information

No response

prabhatm8000 commented 9 months ago

same issue. 🙂🥲

SAROND-DEV commented 9 months ago

I found a simple solution, but I not sure if it the best idea.

cookiejar.setCookieSync(cookie, url, { ignoreError: true })
zS1L3NT commented 3 months ago

Version v5.2.2 has been released with this bug fixed. I set the cookie url to www.youtube.com instead of music.youtube.com and it worked