diegosouzapw/OmniRoute · error
Unsupported origin protocol
Error message
Unsupported origin protocol
What it means
Validation error thrown by normalizeOrigin() when an Origin header value parses as a URL but its protocol is neither http: nor https: (e.g. null, chrome-extension:, ws:, or a malformed custom scheme). It guards the public-origin allowlist against non-HTTP origin values.
Solutions
- Send a standard http:// or https:// Origin header from the client
- Strip or ignore non-HTTP origins at the CORS layer before normalization
- If the client cannot send an origin (native apps, curl), omit the Origin header rather than sending a non-HTTP scheme
- Check for browser extensions or embedded webviews injecting unusual origin schemes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/server/origin/publicOrigin.ts:46 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/756469e11c908951.
Report an issue: GitHub.
Appendix: source
Thrown at src/server/origin/publicOrigin.ts:46
const seen = new Set<string>();
const result: PublicOriginCandidate[] = [];
for (const candidate of candidates) {
const normalized = normalizeOrigin(candidate.origin);
if (seen.has(normalized)) continue;
seen.add(normalized);
result.push({ ...candidate, origin: normalized });
}
return result;
}
export function firstHeaderValue(value: string | null): string | null {
return value?.split(",")[0]?.trim() || null;
}
export function normalizeOrigin(origin: string): string {
const parsed = new URL(origin);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
throw new Error("Unsupported origin protocol");
}
return parsed.origin.toLowerCase();
}
function configuredPublicOrigins(): PublicOriginCandidate[] {
const candidates: PublicOriginCandidate[] = [];
for (const name of PUBLIC_BASE_URL_ENV) {
const value = process.env[name]?.trim();
if (!value) continue;
try {
candidates.push({ origin: normalizeOrigin(value), source: "configured" });
} catch {
continue;
}
}
return candidates;
}
View on GitHub (pinned to a179ffed5b)