Overview
The thumbnail proxy endpoint fetches external thumbnail images and serves them with CORS headers enabled. This allows client-side JavaScript to manipulate images from external domains using canvas operations.Endpoint Details
GET
/api/thumbnail-proxy
Query Parameters
The URL of the thumbnail image to proxy. Must be from an allowed domain.
Allowed Domains
For security, only images from the following domains are permitted:usercontent.donorkit.iocdn.lakeozarkdisciples.orgimg.youtube.com
403 Forbidden error.
Response
Success Response (200 OK)
The image data as a binary buffer
The MIME type of the image (e.g.,
image/jpeg, image/png). Defaults to image/jpeg if not provided by the source.Set to
* to allow cross-origin requests from any domainSet to
GETSet to
public, max-age=86400 (24 hours)Error Responses
Returned when the
url query parameter is missingReturned when the image URL is from a domain not in the allowed list
Returned when the source image cannot be fetched (proxies the upstream status)
Returned when an unexpected error occurs during processing
Example Requests
Using JavaScript Fetch
Using cURL
Loading into Canvas
Use Cases
- Canvas Manipulation: Fetch YouTube thumbnails for client-side image processing
- Custom Thumbnails: Proxy custom church thumbnails stored on CDN
- CORS Bypass: Access images from external domains that don’t provide CORS headers
- Caching: Take advantage of 24-hour browser caching for frequently accessed images
Implementation Details
The endpoint:- Validates that the
urlparameter is provided - Checks that the URL hostname is from an allowed domain
- Fetches the image from the source URL
- Returns the image with CORS headers to enable cross-origin access
- Includes cache headers for 24-hour browser caching