{"record":{"id":"4136ce4c4a56e5d5","repo":"FlowiseAI/Flowise","slug":"too-many-redirects","errorCode":null,"errorMessage":"Too many redirects","messagePattern":"Too many redirects","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/src/httpSecurity.ts","lineNumber":205,"sourceCode":"        }\n\n        const response = await axios(currentConfig)\n\n        // If it's a successful response (not a redirect), return it\n        if (response.status < 300 || response.status >= 400) {\n            return response\n        }\n\n        // Handle redirect\n        const location = response.headers.location\n        if (!location) {\n            // No location header, but it's a redirect status - return the response\n            return response\n        }\n\n        redirects++\n        if (redirects > maxRedirects) {\n            throw new Error('Too many redirects')\n        }\n\n        currentUrl = new URL(location, currentUrl).toString()\n\n        // For redirects, we only need to preserve certain headers and change method if needed\n        if (response.status === 301 || response.status === 302 || response.status === 303) {\n            // For 303, or when redirecting POST requests, change to GET\n            if (\n                response.status === 303 ||\n                (currentConfig.method && ['POST', 'PUT', 'PATCH'].includes(currentConfig.method.toUpperCase()))\n            ) {\n                currentConfig.method = 'GET'\n                delete currentConfig.data\n            }\n        }\n    }\n\n    throw new Error('Too many redirects')","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/httpSecurity.ts#L187-L223","documentation":"Thrown by secureAxiosRequest() when the redirect counter exceeds maxRedirects (default 5) during a redirect chain. Each 3xx response with a Location header increments the counter; on the increment past the limit (line 204), this error is thrown. This prevents infinite-redirect loops and bounds redirect-chain traversal so that every hop can be validated against the deny list.","triggerScenarios":"Calling secureAxiosRequest() against a URL whose redirect chain is longer than maxRedirects. For example: a shortlink service that chains through 6+ redirects, or a misconfigured server that redirects A→B→A (loop) where each hop returns a Location. The check at line 204 fires after incrementing.","commonSituations":"Shortlink/URL-shortener endpoints with multi-hop chains. CDNs that redirect across regional endpoints. A misconfigured vhost that redirects HTTP→HTTPS→HTTP in a loop. OAuth flows that redirect several times. Default maxRedirects=5 is too low for some legitimate chains.","solutions":["Pass a higher maxRedirects value as the second argument to secureAxiosRequest(config, 10).","Investigate the redirect chain with curl -L -v or a manual follow to identify a loop or unnecessary hops.","Fix the server-side redirect loop if the chain is unintentional.","Cache the final resolved URL so subsequent requests skip the chain."],"exampleFix":"// before\nconst resp = await secureAxiosRequest(config) // default maxRedirects=5\n\n// after\nconst resp = await secureAxiosRequest(config, 15) // allow longer chain","handlingStrategy":"retry","validationCode":"// Resolve the final URL by following redirects once, then cache it\nasync function resolveFinalUrl(startUrl: string, maxHops = 10): Promise<string> {\n  let url = startUrl\n  for (let i = 0; i < maxHops; i++) {\n    const r = await fetch(url, { redirect: 'manual' })\n    const loc = r.headers.get('location')\n    if (!loc || (r.status < 300 || r.status >= 400)) return url\n    url = new URL(loc, url).toString()\n  }\n  return url\n}\n\nconst finalUrl = await resolveFinalUrl(targetUrl)\nawait secureAxiosRequest({ ...config, url: finalUrl }, 5)","typeGuard":null,"tryCatchPattern":"try {\n  return await secureAxiosRequest(config, maxRedirects)\n} catch (e) {\n  if (String(e) === 'Too many redirects') {\n    // optionally retry once with a higher limit, or surface a clear error\n    return secureAxiosRequest(config, maxRedirects + 5)\n  }\n  throw e\n}","preventionTips":["Pass an explicit maxRedirects sized for the specific endpoint.","Resolve and cache final URLs for frequently-fetched resources.","Investigate loops promptly — they waste budget and mask config errors."],"tags":["http","redirects","network","axios"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}