diegosouzapw/OmniRoute · error · Error

Subscription fetch redirected without Location

Error message

Subscription fetch redirected without Location

What it means

Redirect handling guard in doSafeFetch(): the upstream returned a 3xx redirect but sent no Location header, so the safe fetch cannot resolve the redirect target to re-validate and follow. A redirect without Location is malformed and cannot be safely pursued.

Solutions

  1. Fix the subscription server so redirects include a Location header.
  2. Update the stored subscription URL to the final destination so no redirect is needed.
  3. Retry from a different mirror that responds 200 directly.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/lib/proxySubscription/subscriptionService.ts:335 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/0fe0ee969d016926. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/proxySubscription/subscriptionService.ts:335

    }
  }
}

/**
 * Single fetch attempt: SSRF-validate the target, fetch with manual redirect
 * handling, and re-validate any redirect target. Throws on non-2xx or a
 * blocked target. Each attempt owns its own timeout so a retry after a fast
 * failure isn't killed by the previous attempt's timer.
 */
async function doSafeFetch(url: string, headers: Record<string, string>): Promise<string> {
  await assertSafeFetchTarget(url);
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), SUBSCRIPTION_FETCH_TIMEOUT_MS);
  try {
    const res = await fetch(url, { redirect: "manual", signal: controller.signal, headers });
    if (res.status >= 300 && res.status < 400) {
      const loc = res.headers.get("location");
      if (!loc) throw new Error("Subscription fetch redirected without Location");
      // Resolve relative redirects and re-validate the target (SSRF guard).
      const next = new URL(loc, url).toString();
      await assertSafeFetchTarget(next);
      const res2 = await fetch(next, { redirect: "manual", signal: controller.signal, headers });
      if (res2.status >= 300 && res2.status < 400) {
        throw new Error("Subscription fetch: too many redirects");
      }
      if (!res2.ok) {
        throw new Error(`Subscription fetch failed: HTTP ${res2.status}`);
      }
      return await res2.text();
    }
    if (!res.ok) {
      throw new Error(`Subscription fetch failed: HTTP ${res.status}`);
    }
    return await res.text();
  } finally {
    clearTimeout(timeout);

View on GitHub (pinned to a179ffed5b)