CORS proxy

A browser won't let a page read a feed from another site unless that site allows it. In May 2023 I wrote a 42-line Cloudflare Worker to get around that for my own news readers. In 2026 I found I'd published an open relay, and rewrote it to be safe by default.

Code on GitHub

Made
, rewritten
Built with
Cloudflare Workers, JavaScript, no dependencies
Status
Open source, MIT

The question

Could a few static pages read RSS feeds, news APIs and article pages straight from the browser, with no server of my own? Most feeds don't send CORS headers, so the browser throws the response away even though the request succeeded. A proxy that fetches the URL and adds the missing header fixes that. The question was how small one could be.

How it works

A page asks the Worker for ?url= followed by the address it wants. The Worker fetches it and sends the body back with Access-Control-Allow-Origin set to that page's site. The 2026 version is still one file with no dependencies, and it adds these checks:

Evidence

The 2023 version was 42 lines, written in about an hour: the repository has seven commits between 22:13 and 23:13 on 1 May 2023. Four people starred it and three forked it.

The 2026 version is 163 lines with 16 tests, run with Node's built-in test runner and a stubbed fetch. They cover allowed and refused sites, the preflight, methods, 19 local, private and malformed targets, the host list, headers in both directions, redirects (including one that points at the metadata address), size limits with and without a length header, timeouts and HEAD. I also ran it in Cloudflare's local Workers runtime against real sites: a live RSS feed, an http to https redirect, and each kind of refusal.

What didn't work

The 2023 version was an open relay. It took any site, any method (POST, PUT and DELETE included) and any URL, so anyone who found a deployment could send any request through it. It also forwarded every header it received, cookies and Authorization included, to whatever address it was given. I didn't look at it again for three years.

Two smaller bugs turned up in the rewrite. The README promised a browser-like User-Agent, but the code set it on the preflight response, where it does nothing, and never on the request it sent. And the setup steps told you to replace a string that wasn't in the code.

The rewrite still has limits. The site check only stops browsers, since a script can claim to be any site, so a public deployment should also set the host list. The private-address check reads the URL, not DNS, because a Worker can't look names up itself.