fix(weread): use same-origin web API instead of i.weread.qq.com private API#1710
Open
lw-yang wants to merge 2 commits into
Open
fix(weread): use same-origin web API instead of i.weread.qq.com private API#1710lw-yang wants to merge 2 commits into
lw-yang wants to merge 2 commits into
Conversation
…te API WeRead's auth cookie (wr_skey) is a host-only cookie bound to weread.qq.com and is NOT sent to the subdomain i.weread.qq.com. This causes all commands using fetchPrivateApi to fail with AUTH_REQUIRED even when the user is logged in. Add fetchWebApiWithCookies() that hits the same-origin web API (weread.qq.com/web/*) which correctly receives auth cookies, and migrate all affected commands (book, highlights, notes, shelf, notebooks) to use it. Fixes jackwener#1709 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…equivalent The /user/notebooks endpoint only exists on i.weread.qq.com and has no /web/ counterpart. This command remains affected by the cookie issue and cannot be fixed with the same-origin approach. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
fetchWebApiWithCookies()toutils.js— same-origin GET with cookies toweread.qq.com/web/*book,highlights,notes,shelffromfetchPrivateApi(hitsi.weread.qq.com) tofetchWebApiWithCookieswr_skeyis a host-only cookie onweread.qq.com, never sent to subdomaini.weread.qq.comProblem
All commands using
fetchPrivateApifail withAUTH_REQUIREDeven when the user is logged in:Verified the browser itself cannot authenticate to
i.weread.qq.com:Why
ai-outlinewas unaffectedai-outline.jsalready uses its ownpostWebApiWithCookies()hittingweread.qq.com/web/book/chapterInfos(same-origin), which correctly receives cookies.Not fixed:
notebooks/user/notebooksonly exists oni.weread.qq.com— there is no/web/user/notebooksequivalent (returns 404). This command cannot be fixed with the same-origin approach and remains affected.Local verification
All migrated commands tested successfully after patching:
opencli weread book 855812— returns full metadataopencli weread shelf— returns shelf without fallback warningopencli weread highlights 855812— returns highlightsopencli weread notes 855812— returns notesFixes #1709