This provides a simple CORS proxy, which is designed to run as a Cloudflare Worker.
This system is compatible with wabac.js-based tools, including ArchiveWeb.page Express and ReplayWeb.page
(Originally refactored from CORS proxy used in oldweb-today and currently used in ArchiveWeb.page Express)
The proxy is designed to be usable with regular browser fetch()
.
Since fetch does not handle redirect requests, the proxy wraps any 3xx response and returns a 200 response with the headers set:
Response headers:
x-redirect-status
- redirect status codex-redirect-statusText
- redirect status textx-orig-location
- value ofLocation
header
The proxy also handles custom cookie headers, in case they are not sent/filtered out, such as in service workers
Request header:
x-proxy-cookie
- passed asCookie
header to upstream server.x-profy-referer
- passed asReferer
header to upstream server. TheOrigin
header is also updated based on value of referer, if it exists.
Response header:
x-proxy-set-cookie
- returned from upstreamSet-Cookie
header in case it gets filtered out.
Note: CloudFlare wrangler
cli tool is required. To login, use wrangler login
to login to your Cloudflare Account.
-
Set the
CORS_ALLOWED_ORIGINS
to a list of allowed urls, or set to null to allow any origin. -
Deploy with
wrangler publish