Features
- Proxies images from external URLs
- Preserves original content type
- Configurable cache control headers
- Custom user agent support
- Validates URLs to block SSRF (private IPs, localhost, non-HTTPS)
- Optional domain allowlist via allowedDomains
- Requires Node.js runtime (uses DNS resolution for hostname validation)
- Handles errors gracefully
Basic usage
With options
Why use a proxy?
- Bypass CORS: Your server fetches the image and serves it from your domain
- Caching: Reduce external requests with configurable cache headers
- Privacy: Hide the original image URL from client-side code
- Reliability: Handle external failures gracefully
API Reference
Response
Error handling
- 400: Missing URL parameter or URL failed validation (blocked domain, private IP, etc.)
- 500: Failed to fetch the image
- Original status: If the external server returns an error, that status is forwarded
Use with useOgData hook
Security considerations
- Only HTTPS URLs are allowed
- Private IPs, localhost, and link-local addresses are blocked
- Embedded credentials in URLs are rejected
- Redirect chains are followed and re-validated (up to 3 redirects)