JuliusBrussee/caveman · error

must use https (plain http is allowed only for localhost)

Error message

${label} must use https (plain http is allowed only for localhost)

What it means

Security guard in requireBaseUrl: the parsed base URL uses plain http while its host is not localhost. Credentials ride every request to this host, so non-loopback plaintext http is refused to keep keys off the wire in cleartext.

Solutions

  1. Switch the base URL to https for any non-localhost host
  2. Use http://localhost or http://127.0.0.1 for local development only
  3. Terminate TLS at the proxy or use an https tunnel (e.g. ngrok) when testing remote instances
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/mastra/src/index.ts:828 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/ec3acaeacd825ea4. Report an issue: GitHub.

Appendix: source

Thrown at packages/mastra/src/index.ts:828

function requireNonEmpty(value: string | undefined, label: string): string {
  if (typeof value !== "string" || value.trim() === "") throw new Error(`${label} is required`);
  return value.trim();
}

function requireBaseUrl(value: string | undefined, label: string): string {
  const raw = requireNonEmpty(value, label);
  let parsed: URL;
  try {
    parsed = new URL(raw);
  } catch {
    throw new Error(`${label} must be an absolute http(s) URL`);
  }
  // Credentials ride every request to this host. Plain http is allowed only
  // for loopback development targets — anywhere else the key or session token
  // would transit unencrypted to a caller-chosen host.
  const loopback = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname === "[::1]";
  if (parsed.protocol === "http:" && !loopback) {
    throw new Error(`${label} must use https (plain http is allowed only for localhost)`);
  }
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
    throw new Error(`${label} must be an absolute http(s) URL`);
  }
  return trimTrailingSlashes(raw);
}

function trimTrailingSlashes(value: string): string {
  return value.replace(/\/+$/, "");
}

function isObject(value: unknown): value is object {
  return typeof value === "object" && value !== null;
}

function isPlainObject(value: unknown): value is Record<string, unknown> {
  if (!isObject(value) || Array.isArray(value)) return false;
  const proto: unknown = Object.getPrototypeOf(value);

View on GitHub (pinned to 766dce6b13)