Skip to content

Answer CORS preflight requests, and fix ferris's add-a-hit response missing it entirely - #80

Merged
p3k merged 1 commit into
mainfrom
fix-cors-preflight-and-ferris-ping
Sep 28, 2026
Merged

p3k merged 1 commit into
mainfrom
fix-cors-preflight-and-ferris-ping

Conversation

@p3k

@p3k p3k commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Live bug, actively breaking embedded boxes on third-party sites right now.

  • Both services are meant to be called from any page embedding a box, but Flask’s own automatic OPTIONS response to a preflight request never runs through roxy()/ferris() at all – it answers before the view function is called – so it never got the Access-Control-Allow-Origin header those functions set.
  • A request stops being CORS-simple (no preflight needed) past a certain Accept header length, which rss-box just crossed after adding JSON Feed to its Accept list – breaking every embedded box on every third-party page, not just JSON Feed ones, since the preflight now fails before the real request is ever sent. (Companion fix on the rss-box side trims the Accept header back under that limit.)
  • Along the way, found ferris()’s own add-a-hit response (the actual per-embed referrer ping) never set the header at all, on any request, preflighted or not – silently broken via CORS from the start, independent of today’s regression.
  • Centralized in one app.after_request hook instead of setting it in each response path, so a future response path can’t repeat the same mistake.

Test plan

  • Verified directly against a real local server: a preflight OPTIONS request to /roxy now gets Access-Control-Allow-Origin, Access-Control-Allow-Headers, and Access-Control-Allow-Methods; a real GET to /ferris’s add-a-hit path now gets Access-Control-Allow-Origin too
  • Full test.sh suite passes
  • entrecote.py’s own smoke test (including the concurrency regression check) still passes

🤖 Generated with Claude Code

…issing it entirely

Both services are meant to be called from any page embedding a box,
but Flask’s own automatic OPTIONS response to a preflight request
never ran through roxy()/ferris() at all – it answers before the view
function is called – so it never got the Access-Control-Allow-Origin
header those functions set. A request stops being CORS-simple (no
preflight needed) past a certain Accept header length, which rss-box
just hit after adding JSON Feed to its Accept list – breaking every
embedded box on every third-party page, not just JSON Feed ones,
since the preflight now fails before the real request is ever sent.

Along the way, found ferris()’s own add-a-hit response (the actual
per-embed referrer ping) never set the header at all, on any request,
preflighted or not – silently broken via CORS from the start,
independent of today’s regression.

Centralized in one app.after_request hook instead of setting it in
each response path, so a future response path can’t repeat the same
mistake. Verified directly: a real preflight OPTIONS request to /roxy
now gets Access-Control-Allow-Origin, Access-Control-Allow-Headers,
and Access-Control-Allow-Methods; a real GET to /ferris’s add-a-hit
path now gets Access-Control-Allow-Origin too. Full test suite and
entrecote’s own smoke test still pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@p3k
p3k merged commit 731a589 into main Sep 28, 2026
6 checks passed
@p3k
p3k deleted the fix-cors-preflight-and-ferris-ping branch September 28, 2026 07:25
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.

1 participant