Skip to content

fix: ignore font and modern static-asset extensions#71

Open
marcin-prerender wants to merge 1 commit into
prerender:masterfrom
marcin-prerender:fix/ignore-woff2-and-modern-static-assets
Open

fix: ignore font and modern static-asset extensions#71
marcin-prerender wants to merge 1 commit into
prerender:masterfrom
marcin-prerender:fix/ignore-woff2-and-modern-static-assets

Conversation

@marcin-prerender

Copy link
Copy Markdown

Bug

@extensions_to_ignore ends at .torrent — there is no font, SVG, or modern image filtering at all. Every bot request for a .woff2/.ttf/.svg/.webp/etc. asset is forwarded to the Prerender service, which rejects static-asset URLs with 504. The result is a crawler-visible 5xx for every font/image a bot fetches through the middleware.

Live evidence

Verified against prerender.io's own assets: requesting inter-*.woff2 with a Googlebot user agent returns 504, while a normal browser UA returns 200.

Canonical contract

This aligns the middleware with the canonical static-asset ignore list, which now includes .woff2 .otf .eot .webp .avif .webmanifest: prerender/integration-contract#1

Changes

  • lib/prerender_rails.rb: add .ttf .otf .woff .woff2 .eot .svg .webp .avif .webmanifest to @extensions_to_ignore; remove the duplicated .doc entry.
  • test/lib/prerender_rails.rb: add a test mirroring the existing resource-file test for a font request (/fonts/inter.woff2) asserting the request continues to the app instead of being proxied.

Matching semantics are deliberately left as-is: the check is request.fullpath.include?(extension) — a case-sensitive substring match over path and query string. Side note: this already over-matches today (e.g. .ai matches any URL containing .ai, such as example.ai domains in query params, and /blog/what-is-a-pdf is unaffected but ?file=x.pdf is filtered); tightening that to a real extension check is out of scope for this PR.

Tests

bundle install && ruby -Ilib test/lib/prerender_rails.rb (Ruby 2.6.10, Bundler 2.1.4; RUBYOPT=-rlogger to work around the unrelated concurrent-ruby 1.3.5 / ActiveSupport 6.1 Logger autoload issue): 28 runs, 36 assertions, 0 failures, 0 errors, including the new font test.

🤖 Generated with Claude Code

Add .ttf, .otf, .woff, .woff2, .eot, .svg, .webp, .avif and
.webmanifest to @extensions_to_ignore and remove the duplicated
.doc entry. The list previously ended at .torrent, so no font, SVG
or modern image format was filtered at all: every bot request for
such an asset was forwarded to the Prerender service, which rejects
static assets with 504. Verified live that Googlebot requesting
prerender.io's own inter-*.woff2 receives a 504 (a normal UA gets
200), so these forwarded requests surface as crawler-visible 5xx.
Aligns with the canonical static-asset ignore list in
prerender/integration-contract#1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants