A lightning-fast, simple CORS proxy server written in Go. Deploy anywhere with one click!
Try it now: https://corsproxy-8uo5.onrender.com
Example:
# Fetch GitHub API through the proxy
curl "https://corsproxy-8uo5.onrender.com/?url=https://api.github.com/users/melihbirim"
# Use in JavaScript
fetch('https://corsproxy-8uo5.onrender.com/?url=https://api.example.com/data')
.then(r => r.json())
.then(data => console.log(data));- β‘ Fast: Written in Go for maximum performance
- π³ Docker Ready: Full Docker and Docker Compose support
- π One-Click Deploy: Deploy to Railway, Render, Fly.io, or Koyeb
- π Full CORS Support: Handles all CORS headers automatically
- π¦ Zero Dependencies: Uses only Go standard library
- π Secure: 10MB request size limit, 30s timeout
- πΎ Lightweight: ~10MB Docker image (Alpine-based)
# Clone the repository
git clone https://github.com/melihbirim/corsproxy.git
cd corsproxy
# Run directly with Go
go run main.go
# Or use Make
make run
# Or build and run
make build
./bin/corsproxyServer starts at http://localhost:8080
# Make sure server is running in another terminal
make test
# Or run directly
./test.sh# Build and run with Docker
docker build -t corsproxy .
docker run -p 8080:8080 corsproxy
# Or use Docker Compose
docker-compose up# Using the development Dockerfile
docker build -f Dockerfile.dev -t corsproxy-dev .
docker run -p 8080:8080 -v $(pwd):/app corsproxy-devcurl "http://localhost:8080/?url=https://api.example.com/data"fetch("http://localhost:8080/?url=https://api.example.com/data")
.then((response) => response.json())
.then((data) => console.log(data));fetch("http://localhost:8080/?url=https://api.example.com/data", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer token123",
},
body: JSON.stringify({ key: "value" }),
})
.then((response) => response.json())
.then((data) => console.log(data));curl http://localhost:8080/healthResponse:
{ "status": "ok", "timestamp": "2026-01-08T12:00:00Z" }- Click the "Deploy on Railway" button above
- Connect your GitHub repository
- Railway will auto-detect and deploy
- Your proxy will be live at
https://your-app.railway.app
- Click the "Deploy to Render" button above
- Connect your repository
- Render will build and deploy automatically
- Access at
https://your-app.onrender.com
# Install flyctl
curl -L https://fly.io/install.sh | sh
# Login
flyctl auth login
# Deploy
flyctl launch# Install Koyeb CLI
curl -fsSL https://cli.koyeb.com/install.sh | sh
# Login
koyeb login
# Deploy
koyeb app create corsproxy \
--git github.com/melihbirim/corsproxy \
--git-branch main \
--ports 8080:http \
--routes /:8080| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
Server port |
MAX_REQUEST_SIZE |
10485760 |
Max request size in bytes (10MB default) |
REQUEST_TIMEOUT |
30s |
Request timeout (Go duration: 30s, 1m, etc) |
MAX_REDIRECTS |
10 |
Maximum number of redirects to follow |
ALLOWED_ORIGINS |
* |
CORS allowed origins (* for all, or comma-separated list) |
ALLOWED_HOSTS |
`` | Comma-separated list of allowed hosts (empty = all) |
BLOCKED_HOSTS |
`` | Comma-separated list of blocked hosts |
RATE_LIMIT_PER_MINUTE |
0 |
Rate limit per IP (0 = disabled) |
VERBOSE_LOGGING |
false |
Enable detailed request logging |
# .env file or deployment settings
PORT=8080
MAX_REQUEST_SIZE=5242880 # 5MB
REQUEST_TIMEOUT=15s
RATE_LIMIT_PER_MINUTE=100 # 100 requests per minute per IP
ALLOWED_ORIGINS=https://example.com,https://app.example.com,https://admin.example.com
ALLOWED_HOSTS=api.github.com,api.stripe.com,httpbin.org
BLOCKED_HOSTS=localhost,127.0.0.1,192.168.0.0
VERBOSE_LOGGING=trueCORS Origins:
# Allow all origins (development only)
ALLOWED_ORIGINS=*
# Allow specific origins (production recommended)
ALLOWED_ORIGINS=https://example.com,https://app.example.comHost Filtering:
# Only allow specific APIs
ALLOWED_HOSTS=api.github.com,api.stripe.com
# Block internal networks
BLOCKED_HOSTS=localhost,127.0.0.1,192.168.0.0,10.0.0.0Rate Limiting:
# Limit to 100 requests per minute per IP address
RATE_LIMIT_PER_MINUTE=100Request Limits:
# Smaller file size limit for production
MAX_REQUEST_SIZE=5242880 # 5MB
# Faster timeout for better resource usage
REQUEST_TIMEOUT=15scorsproxy/
βββ main.go # Main application
βββ go.mod # Go module file
βββ Makefile # Build automation
βββ test.sh # Test script
βββ Dockerfile # Production Docker image
βββ Dockerfile.dev # Development Docker image
βββ docker-compose.yml # Docker Compose config
βββ railway.json # Railway deployment config
βββ render.yaml # Render deployment config
βββ fly.toml # Fly.io deployment config
βββ koyeb.json # Koyeb deployment config
βββ .env.example # Environment variables template
βββ README.md # This filemake help # Show all available commands
make build # Build the binary
make run # Run the server
make test # Run tests
make docker-build # Build Docker image
make docker-run # Run Docker container
make clean # Clean build artifacts
make fmt # Format code
make lint # Lint codeProxies the request to the target URL with CORS headers.
Query Parameters:
url(required): The target URL to proxy
Example:
curl "http://localhost:8080/?url=https://api.github.com/users/octocat"Health check endpoint for monitoring.
Response:
{ "status": "ok", "timestamp": "2026-01-08T12:00:00Z" }- URL validation (must start with http:// or https://)
- Request size limiting (10MB max)
- Request timeout (30s)
- Redirect limit (max 10 redirects)
- No arbitrary code execution
- Cold Start: < 100ms
- Request Latency: < 50ms overhead
- Memory Usage: ~10MB base
- Concurrent Requests: Thousands (Go's goroutines)
MIT License - feel free to use this in your projects!
We welcome contributions! This project is perfect for learning Go and building production-ready software.
Looking to contribute? Check out our Good First Issues - production enhancements perfect for first-time contributors:
Priority 1 (Great for beginners):
- Add graceful shutdown handling
- Implement request ID middleware
- Add structured JSON logging
- Add security headers (CSP, HSTS, etc)
Priority 2 (Intermediate):
- Add Prometheus metrics endpoint
- Implement response caching
- Add API key authentication
- Add circuit breaker pattern
See CONTRIBUTING.md for detailed guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests:
make test - Run linter:
make lint - Commit your changes (
git commit -m 'Add: amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
| Feature | This Proxy | CORS Anywhere | corsproxy-node |
|---|---|---|---|
| Language | Go | Node.js | Node.js |
| Docker Support | β | β | |
| One-Click Deploy | β | β | |
| Memory Usage | ~10MB | ~50MB | ~40MB |
| Cold Start | <100ms | ~1s | ~800ms |
| Dependencies | 0 | Many | Many |
- Bypass CORS restrictions in development
- Access APIs that don't support CORS
- Build web applications that need to fetch external resources
- Create API gateways with CORS support
- Testing and prototyping
While this proxy is production-ready, consider:
- Rate Limiting: Add rate limiting for public deployments
- Authentication: Add API keys if needed
- Monitoring: Use the
/healthendpoint for uptime monitoring - Logging: Logs are written to stdout (Docker-friendly)
- Caching: Consider adding caching for frequently accessed resources
# Change port via environment variable
PORT=3000 go run main.go# Clean Docker cache
docker builder prune
docker build --no-cache -t corsproxy .The proxy has a 30-second timeout. For longer requests, modify the client.Timeout in main.go.
- Open an issue on GitHub
- Check existing issues for solutions
- Read the code - it's simple and well-commented!
Made with β€οΈ by @melihbirim
Star β this repository if you find it useful!