Skip to content

bao3/api-proxy

Repository files navigation

API Proxy Service

English | 中文

A simple API proxy service built with Nitro framework. It forwards HTTP requests to configured target APIs based on request paths.

🚀 Quick Start

Deploy to Vercel

Note: Please be aware of Vercel's free plan usage limits. Public deployment is not recommended to prevent abuse.

Deploy to Vercel

Deploy to Cloudflare

Deploy to Cloudflare

📝 What This Project Does

This is a simple reverse proxy that:

  • Takes HTTP requests on specific paths (e.g., /openai/**)
  • Forwards them to configured target servers (e.g., https://api.openai.com)
  • Returns the response back to the client
  • Removes client IP headers for basic privacy

It's useful for:

  • Bypassing CORS restrictions in web applications
  • Hiding API endpoints behind a single domain
  • Adding a simple layer between clients and APIs

🌟 Features

  • Request Forwarding: Forwards HTTP requests including headers, body, and query parameters
  • Privacy Protection: Removes client IP headers (x-forwarded-for, x-real-ip) from forwarded requests
  • Environment Configuration: Configure proxy targets via environment variables
  • Optional Dashboard: Simple web interface to view configured endpoints
  • Lightweight: Minimal dependencies, built with Nitro framework

⚙️ Configuration

Environment Variables

Configure proxy targets using the pattern PROXY_{NAME}_TARGET:

# Basic proxy configurations
PROXY_GEMINI_TARGET=https://generativelanguage.googleapis.com
PROXY_OPENAI_TARGET=https://api.openai.com
PROXY_ANTHROPIC_TARGET=https://api.anthropic.com

# Optional: Enable homepage dashboard
HOMEPAGE_ENABLE=true

Proxy Configuration Table

Endpoint Path Target URL Environment Variable Description
/gemini/** https://generativelanguage.googleapis.com PROXY_GEMINI_TARGET=https://generativelanguage.googleapis.com Google Gemini API
/openai/** https://api.openai.com PROXY_OPENAI_TARGET=https://api.openai.com OpenAI API
/anthropic/** https://api.anthropic.com PROXY_ANTHROPIC_TARGET=https://api.anthropic.com Anthropic API

Adding New Proxies

To add a new proxy endpoint, simply add an environment variable following the naming pattern:

# Forward /myapi/** requests to https://api.example.com
PROXY_MYAPI_TARGET=https://api.example.com

# Forward /v1/chat/** requests to https://chat.example.com
PROXY_V1_CHAT_TARGET=https://chat.example.com

The service will automatically:

  • Convert PROXY_MYAPI_TARGET to route /myapi/**
  • Convert PROXY_V1_CHAT_TARGET to route /v1/chat/**

📊 Dashboard

When HOMEPAGE_ENABLE=true, accessing the root URL shows:

  • List of configured proxy endpoints
  • Target URLs for each endpoint
  • Copy buttons for quick URL copying

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •