fetch url https://www.youtube.com/iframe_api error #506

Closed
opened 2025-11-09 09:51:07 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @xuya227939 on GitHub (Oct 15, 2024).

problem description

Describe your suggestion

I use proxy, but get error

Error

Line:40 🍷 url https://www.youtube.com/iframe_api
Fetch error for https://www.youtube.com/iframe_api. Retrying in 2 seconds...

Line:40 🍷 url https://www.youtube.com/sw.js_data
Fetch error for https://www.youtube.com/sw.js_data. Retrying in 2 seconds...

Tell me why? Please, Thank you.

Code

const initializeInnertube = async () => {
  const proxyAgent = new HttpsProxyAgent(
    "https://v2sub.com/xxx"
  );
  return await Innertube.create({
    fetch: async (input, init) => {
      const url =
        typeof input === "string"
          ? input
          : input instanceof URL
          ? input.toString()
          : input.url;

      const modifiedInit = {
        ...init,
        method: init?.method || (init?.body ? "POST" : "GET"),
        agent: proxyAgent,
      };
      if (modifiedInit.method === "POST")
        modifiedInit.headers = {
          ...modifiedInit.headers,
          "Content-Type": "application/json",
        };

      const maxRetries = 5;
      let retryCount = 0;
      const fetchWithRetry = async () => {
        try {
          const response = await fetch(url, modifiedInit);
          if (!response.ok) {
            if (response.status === 429) {
              console.warn(
                `Too Many Requests. Retrying in ${delayTime / 1000} seconds...`
              );
            }
            throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
          }
          return response;
        } catch (error) {
          throw new Error(`Fetch error for ${url}: ${error.message}`);
        }
      };

      return fetchWithRetry();
    },
  });
};

your instance configuration

No response

Originally created by @xuya227939 on GitHub (Oct 15, 2024). ### problem description ### Describe your suggestion I use proxy, but get error ## Error Line:40 🍷 url https://www.youtube.com/iframe_api Fetch error for https://www.youtube.com/iframe_api. Retrying in 2 seconds... Line:40 🍷 url https://www.youtube.com/sw.js_data Fetch error for https://www.youtube.com/sw.js_data. Retrying in 2 seconds... Tell me why? Please, Thank you. ## Code ``` const initializeInnertube = async () => { const proxyAgent = new HttpsProxyAgent( "https://v2sub.com/xxx" ); return await Innertube.create({ fetch: async (input, init) => { const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url; const modifiedInit = { ...init, method: init?.method || (init?.body ? "POST" : "GET"), agent: proxyAgent, }; if (modifiedInit.method === "POST") modifiedInit.headers = { ...modifiedInit.headers, "Content-Type": "application/json", }; const maxRetries = 5; let retryCount = 0; const fetchWithRetry = async () => { try { const response = await fetch(url, modifiedInit); if (!response.ok) { if (response.status === 429) { console.warn( `Too Many Requests. Retrying in ${delayTime / 1000} seconds...` ); } throw new Error(`Failed to fetch ${url}: ${response.statusText}`); } return response; } catch (error) { throw new Error(`Fetch error for ${url}: ${error.message}`); } }; return fetchWithRetry(); }, }); }; ``` ### your instance configuration _No response_
GiteaMirror added the instance hosting help label 2025-11-09 09:51:07 -06:00
Author
Owner

@wukko commented on GitHub (Oct 20, 2024):

i have no clue how this is related to cobalt in any way, create a new issue describing the issue

@wukko commented on GitHub (Oct 20, 2024): i have no clue how this is related to cobalt in any way, create a new issue describing the issue
Sign in to join this conversation.