Transparent fetch proxy for Vibecode - auto-patches global fetch on import
npm install @vibecodeapp/proxyA transparent fetch proxy that auto-patches global fetch on import. Zero configuration required—just import and go.
``bash`
bun add @vibecodeapp/proxy
`typescript
import '@vibecodeapp/proxy'
// That's it! All fetch requests to supported AI APIs are now proxied.
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: { 'Authorization': 'Bearer sk-...' },
body: JSON.stringify({ model: 'gpt-4', messages: [...] })
})
`
Set your project ID via environment variable:
`bash`
VIBECODE_PROJECT_ID=your-project-id
`typescript
import { setProxyProjectId, setProxiedDomains } from '@vibecodeapp/proxy'
// Set project ID at runtime
setProxyProjectId('your-project-id')
// Override the list of proxied domains
setProxiedDomains([
'api.openai.com',
'api.anthropic.com',
'custom-api.example.com'
])
`
By default, requests to these domains are routed through the proxy:
- api.openai.comapi.anthropic.com
- api.x.ai
- amazonaws.com
- (includes Bedrock)generativelanguage.googleapis.com
- api.elevenlabs.io
-
The proxy also fetches an updated domain list from the server on initialization.
1. Import-time patching: When you import the package, it immediately patches globalThis.fetchproxy.vibecodeapp.com
2. URL matching: Each fetch request is checked against the list of proxied domains
3. Transparent routing: Matching requests are rewritten to go through
4. Credential injection: Your project ID is added to proxied requests for authentication
``
Original: https://api.openai.com/v1/chat/completions
Proxied: https://api.openai.com.proxy.vibecodeapp.com/v1/chat/completions
Set the project ID used for authentication with the proxy.
Override the list of domains that should be routed through the proxy.
Get the original, unpatched fetch function if you need to bypass the proxy.
`typescript
import { getOriginalFetch } from '@vibecodeapp/proxy'
const originalFetch = getOriginalFetch()
await originalFetch('https://api.openai.com/...') // Bypasses proxy
`
- ✅ Node.js
- ✅ Bun
- ✅ Deno
The package also patches undici` when available for better Node.js SDK compatibility.
MIT