diegosouzapw/OmniRoute · error · Error

ChatGPT Cookie header is missing…

Error message

ChatGPT Cookie header is missing __Secure-next-auth.session-token

What it means

Cookie parsing guard in parseCookies (storageState.ts): the supplied cookie header contains no __Secure-next-auth.session-token (with optional numeric suffix) pair. That token is the only credential the ChatGPT Web flow accepts, so a header without it — wrong cookie copied, wrong site's cookies, or a truncated paste — cannot bootstrap the storage state.

Solutions

  1. Copy the full Cookie header from an authenticated chat.openai.com session and re-save it
  2. Make sure the __Secure-next-auth.session-token cookie is included (not just cf_clearance or other cookies)
  3. Re-login to ChatGPT if the dev-tools cookie set no longer contains the session token
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at open-sse/executors/chatgpt-web-codex/storageState.ts:37 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/240b082041c0d051. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/chatgpt-web-codex/storageState.ts:37

  };
}

function cookieHeaderValue(raw: string): string {
  return raw.trim().replace(/^cookie\s*:\s*/i, "");
}

function parseCookies(raw: string): Array<Record<string, unknown>> {
  const header = cookieHeaderValue(raw);
  const pairs = header
    .split(/;\s*/)
    .map((part) => {
      const separator = part.indexOf("=");
      return separator > 0 ? [part.slice(0, separator).trim(), part.slice(separator + 1)] : null;
    })
    .filter((pair): pair is [string, string] => Boolean(pair?.[0]));
  if (!pairs.some(([name]) => /^__Secure-next-auth\.session-token(?:\.\d+)?$/.test(name))) {
    if (header.includes(";") || header.includes("=")) {
      throw new Error("ChatGPT Cookie header is missing __Secure-next-auth.session-token");
    }
    pairs.push(["__Secure-next-auth.session-token", header]);
  }
  return pairs.map(([name, value]) => ({
    name,
    value,
    domain: ".chatgpt.com",
    path: "/",
    secure: true,
    httpOnly: name.startsWith("__Secure-") || name.startsWith("__Host-"),
    sameSite: "Lax",
  }));
}

function cookieFingerprint(raw: string): string {
  return createHash("sha256").update(cookieHeaderValue(raw)).digest("hex");
}

View on GitHub (pinned to a179ffed5b)