FlowiseAI/Flowise · error · Error
Too many redirects
Error message
Too many redirects
What it means
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.
Source
Thrown at packages/components/src/httpSecurity.ts:205
}
const response = await axios(currentConfig)
// If it's a successful response (not a redirect), return it
if (response.status < 300 || response.status >= 400) {
return response
}
// Handle redirect
const location = response.headers.location
if (!location) {
// No location header, but it's a redirect status - return the response
return response
}
redirects++
if (redirects > maxRedirects) {
throw new Error('Too many redirects')
}
currentUrl = new URL(location, currentUrl).toString()
// For redirects, we only need to preserve certain headers and change method if needed
if (response.status === 301 || response.status === 302 || response.status === 303) {
// For 303, or when redirecting POST requests, change to GET
if (
response.status === 303 ||
(currentConfig.method && ['POST', 'PUT', 'PATCH'].includes(currentConfig.method.toUpperCase()))
) {
currentConfig.method = 'GET'
delete currentConfig.data
}
}
}
throw new Error('Too many redirects')View on GitHub (pinned to abe4a8601a)
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.
Example fix
// before const resp = await secureAxiosRequest(config) // default maxRedirects=5 // after const resp = await secureAxiosRequest(config, 15) // allow longer chain
Defensive patterns
Strategy: retry
Validate before calling
// Resolve the final URL by following redirects once, then cache it
async function resolveFinalUrl(startUrl: string, maxHops = 10): Promise<string> {
let url = startUrl
for (let i = 0; i < maxHops; i++) {
const r = await fetch(url, { redirect: 'manual' })
const loc = r.headers.get('location')
if (!loc || (r.status < 300 || r.status >= 400)) return url
url = new URL(loc, url).toString()
}
return url
}
const finalUrl = await resolveFinalUrl(targetUrl)
await secureAxiosRequest({ ...config, url: finalUrl }, 5) Try / catch
try {
return await secureAxiosRequest(config, maxRedirects)
} catch (e) {
if (String(e) === 'Too many redirects') {
// optionally retry once with a higher limit, or surface a clear error
return secureAxiosRequest(config, maxRedirects + 5)
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to fetch ${url}: ${error}
- Failed to post ${url}: ${error}
- ${errorMessage}
- HTTP error! status: ${response.status}
- Oxylabs: Failed to call Oxylabs API: ${response.status}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/4136ce4c4a56e5d5.
Report an issue: GitHub.