Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

640 B
Raw Blame
import { getForwardedHeaders } from './forwarded';

describe('getForwardedHeaders', () => {
  it('reports the hop count instead of the forwarded-for addresses', () => {
    const result = getForwardedHeaders({
      'x-forwarded-for': '203.0.113.7, 198.51.100.2',
      'x-forwarded-host': 'chat.example.com',
      'x-forwarded-proto': 'https',
    });
    expect(result).toEqual({
      'x-forwarded-for-hops': 2,
      'x-forwarded-host': 'chat.example.com',
      'x-forwarded-proto': 'https',
    });
  });

  it('returns nothing when no forwarded header is present', () => {
    expect(getForwardedHeaders({})).toEqual({});
  });
});