This is a Cloudflare worker utilizing its Cache API to cache and serve pictures for RSS feeds.
You can use the FreshRSS image cache plugin to rewrite the RSS feeds to this caching URL.
-
edit
wrangler.tomland set its route and fallback figure url. For example:route = "https://example.com/piccache" [vars] FALLBACK_FIGURE = "https://http.cat/404.jpg"
The CF worker will be bind to the route specified, and when unable to retrieve the figure, it will return
FALLBACK_FIGUREinstead. You may also remove the line ofrouteand it will use*.workers.devinstead. -
Add secrets of
APITOKENUse
wrangler secret put APITOKENto specify the access token. This should be consistent with image cache plugin'saccess_token. -
Deploy the worker
-
Configure the image cache plugin
First, upload the plugin FreshRSS image cache plugin to your freshRSS instance with this guide.
If you use a route like
https://example.com/piccache, the image cache plugin should be configured as:cache_url: "https://example.com/piccache?url=" post_url: "https://example.com/piccache" access_token: "<AS THE APITOKEN ABOVE>" url_encode: true
If you don't use route and get a
*.workers.devfor your worker, the image cache plugin should be configured as:cache_url: "https://some.workers.dev/?url=" post_url: "https://some.workers.dev/" access_token: "<AS THE APITOKEN ABOVE>" url_encode: true
Some RSS feeds may mis-configured their figure loading policies, and cannot retrieve the figure without a specific header. Consider add the URL-headers pair to src/index.ts:25.