{"record":{"id":"3ad58a0126289c30","repo":"continuedev/continue","slug":"node-fetch-cannot-load-url-url-scheme-parse","errorCode":null,"errorMessage":"node-fetch cannot load ${url}. URL scheme \"${parsedURL.protocol.replace(/:$/, \"\")}\" is not supported.","messagePattern":"node-fetch cannot load (.+?)\\. URL scheme \"(.+?)\" is not supported\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/fetch/src/node-fetch-patch.js","lineNumber":77,"sourceCode":"  Response,\n};\n\nconst supportedSchemas = new Set([\"data:\", \"http:\", \"https:\"]);\n\n/**\n * Fetch function\n *\n * @param   {string | URL | import('./request').default} url - Absolute url or Request instance\n * @param   {*} [options_] - Fetch options\n * @return  {Promise<import('./response').default>}\n */\nexport default async function fetch(url, options_) {\n  return new Promise((resolve, reject) => {\n    // Build request object\n    const request = new Request(url, options_);\n    const { parsedURL, options } = getNodeRequestOptions(request);\n    if (!supportedSchemas.has(parsedURL.protocol)) {\n      throw new TypeError(\n        `node-fetch cannot load ${url}. URL scheme \"${parsedURL.protocol.replace(/:$/, \"\")}\" is not supported.`,\n      );\n    }\n\n    if (parsedURL.protocol === \"data:\") {\n      const data = dataUriToBuffer(request.url);\n      const response = new Response(data, {\n        headers: { \"Content-Type\": data.typeFull },\n      });\n      resolve(response);\n      return;\n    }\n\n    // Wrap http.request into fetch\n    const send = (parsedURL.protocol === \"https:\" ? https : http).request;\n    const { signal } = request;\n    let response = null;\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/fetch/src/node-fetch-patch.js#L59-L95","documentation":"node-fetch (patched in packages/fetch) only supports http:, https:, data:, etc. — this TypeError is thrown when the URL's protocol isn't in the supported set.","triggerScenarios":"Calling fetch('ftp://...'), fetch('file:///...'), or a malformed relative URL whose parsed protocol is unsupported.","commonSituations":"Passing a file path instead of a URL, misconfigured base URLs (missing scheme), or feeding browser-style URLs to the Node fetch polyfill.","solutions":["Use an http:// or https:// URL","Prefix bare hostnames with https:// (url = `https://${host}${path}`)","Read local files with fs instead of fetch","Validate protocol with new URL(...) and a whitelist before fetching"],"exampleFix":"// before\nawait fetch('localhost:8080/v1/chat');\n\n// after\nawait fetch('http://localhost:8080/v1/chat');","handlingStrategy":"validation","validationCode":"const u = new URL(url, baseURL); if (!['http:','https:'].includes(u.protocol)) throw new TypeError('unsupported scheme');","typeGuard":"function isHttpUrl(s: string): boolean { try { return ['http:', 'https:'].includes(new URL(s).protocol); } catch { return false; } }","tryCatchPattern":"try { await fetch(url); } catch (e) { if (e instanceof TypeError && /URL scheme/.test(e.message)) { /* fix scheme or use fs */ } else throw e; }","preventionTips":["Always construct URLs via new URL(path, base)","Prepend https:// to scheme-less hostnames","Use fs for local files instead of fetch"],"tags":["fetch","url","node-fetch","validation"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}