Repository navigation
Patch vendored wombat.js to convert POST to GET in fetch() - #379
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #379 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 42 42
Lines 2867 2867
Branches 432 432
=========================================
Hits 2867 2867 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wombat.js's fetch() override only rewrites the request URL: it does not convert a POST (or other non-GET) request to GET the way its XMLHttpRequest override already does, so anything fetched via a POST fetch() call (e.g. YouTube's embedded player fetching its InnerTube player-config) is sent as a literal POST to kiwix-serve, which only serves the GET-converted content baked into the ZIM, and 404s. A fix has been proposed upstream (webrecorder/wombat#242), using wombat's own postToGetUrl(), which flattens the POST body into the query string. That does not match how warc2zim currently names a POST-converted ZIM entry (just `<original-url>&__wb_method=<METHOD>`, body dropped), so this patch intentionally uses that simpler convention instead, to stay consistent with how ZIMs are actually built today. Applied via a new execute_after hook on the wombat.js download in openzim.toml, so every build patches the freshly downloaded wombat.js.
benoit74
force-pushed
the
fix-wombat-fetch-post-to-get
branch
from
November 5, 2026 09:23
7541511 to
2d0451e
Compare
This was referenced Nov 6, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wombat.js'sfetch()override only rewrites the request URL; it does not convert a POST (or other non-GET) request to GET the way itsXMLHttpRequestoverride already does. Anything fetched via a POSTfetch()call (e.g. YouTube's embedded player fetching its InnerTube player-config) is therefore sent as a literal POST to kiwix-serve, which only serves the GET-converted content baked into the ZIM at scrape time, and 404s. The player'sJSON.parse()of the 404 HTML page then throws, breaking video playback right after the user clicks Play.postToGetUrl(), which flattens the POST body into the query string. That does not match how warc2zim currently names a POST-converted ZIM entry (just<original-url>&__wb_method=<METHOD>, with the body dropped — verifiable directly on a built ZIM for theyoutubei/v1/player,youtubei/v1/nextand WAAGenerateITentries), sorules/patch_wombat.pyintentionally uses that simpler, body-dropping convention instead, to stay consistent with how ZIMs are actually built today.execute_afterhook on thewombat.jsdownload action inopenzim.toml, so every build patches the freshly downloadedwombat.js. The script is idempotent (a no-op ifwombat.jsis already patched) and fails loudly if the vendoredwombat.jsno longer matches the expected code, so a future version bump can't silently skip the fix.Reproduced and validated against the real
website.test.openzim.orgYouTube test ZIM: rebuilt it with the patchedwombat.jsand confirmed via a headless browser that the previously-404ingyoutubei/v1/playerrequest now returns 200 and the video actually plays (readyState: 4,paused: false,currentTimeadvancing), versus stuck atreadyState: 0/paused: truebefore the patch.