node-yahoo-finance2 icon indicating copy to clipboard operation
node-yahoo-finance2 copied to clipboard

Newly introduced `getCrumb` function ignores `YF_QUERY_HOST ` from `yahoo-finance.setGlobalConfig`

Open AndriiNeverov opened this issue 1 year ago • 1 comments

Bug Report

Describe the bug

The following new code by @gadicc ignores the host setting:

https://github.com/gadicc/node-yahoo-finance2/blob/2a2d9cce7cc450a015eb4c567a3c862e304631b9/src/lib/getCrumb.ts#L282

export default function getCrumb(
  fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>,
  fetchOptionsBase: RequestInit,
  url = "https://finance.yahoo.com/quote/AAPL",

Minimal Reproduction

yahoo-finance.setGlobalConfig({
  YF_QUERY_HOST: "localhost"
});

is ignored and blocks the CORS workaround.

Environment

Browser or Node: browser Library version (e.g. 1.10.1): 2.4.4

Additional Context

AndriiNeverov avatar Sep 03 '23 02:09 AndriiNeverov

Right you are, @AndriiNeverov, and thanks for the report.

Unfortunately this is not so easy to solve. Although we can trivially fix the url used in the initial request, there are about 4-5 subsequent requests which all rely on redirects from Yahoo to specific addresses, unrelated to the query URL.

Can you give me a bit more background about the CORS workaround you're using? What's on localhost:80 ? Where is it running?

gadicc avatar Sep 03 '23 07:09 gadicc