Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.8 KB
Raw Blame
"use client";

import { useState } from "react";
import { useTranslations } from "next-intl";

interface HeaderTableProps {
  headers: Record<string, string>;
}

export function HeaderTable({ headers }: HeaderTableProps) {
  const t = useTranslations("trafficInspector");
  const [masked, setMasked] = useState(true);
  const SENSITIVE = /authorization|cookie|x-api-key|bearer/i;

  return (
    <div>
      <div className="mb-2 flex items-center gap-2">
        <span className="text-xs text-text-muted">{t("sensitiveHeaders")}</span>
        <button
          type="button"
          onClick={() => setMasked((m) => !m)}
          className="text-xs text-blue-400 hover:text-blue-300 focus-ring rounded"
        >
          {masked ? t("show") : t("hide")}
        </button>
      </div>
      <table className="w-full text-xs font-mono border-collapse bg-surface">
        <thead>
          <tr className="border-b border-border">
            <th className="text-left px-2 py-1 text-text-muted font-medium">{t("name")}</th>
            <th className="text-left px-2 py-1 text-text-muted font-medium">{t("value")}</th>
          </tr>
        </thead>
        <tbody>
          {Object.entries(headers).map(([name, value]) => {
            const isSensitive = SENSITIVE.test(name);
            const display = masked && isSensitive ? "••••••••" : value;
            return (
              <tr key={name} className="border-b border-border/50 hover:bg-bg-subtle">
                <td className="px-2 py-1 text-text-muted select-text">{name}</td>
                <td
                  className={`px-2 py-1 break-all select-text ${isSensitive ? "text-amber-400" : "text-text-main"}`}
                >
                  {display}
                </td>
              </tr>
            );
          })}
        </tbody>
      </table>
    </div>
  );
}