Skip to content

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
jackwener:mainfrom
lw-yang:fix/weread-book-use-web-api
Open

fix(weread): use same-origin web API instead of i.weread.qq.com private API#1710
lw-yang wants to merge 2 commits into
jackwener:mainfrom
lw-yang:fix/weread-book-use-web-api

Conversation

@lw-yang
Copy link
Copy Markdown
Contributor

@lw-yang lw-yang commented May 21, 2026

Summary

  • Add fetchWebApiWithCookies() to utils.js — same-origin GET with cookies to weread.qq.com/web/*
  • Migrate book, highlights, notes, shelf from fetchPrivateApi (hits i.weread.qq.com) to fetchWebApiWithCookies
  • Root cause: wr_skey is a host-only cookie on weread.qq.com, never sent to subdomain i.weread.qq.com

Problem

All commands using fetchPrivateApi fail with AUTH_REQUIRED even when the user is logged in:

$ opencli weread book 855812
error: AUTH_REQUIRED — Not logged in to WeRead

Verified the browser itself cannot authenticate to i.weread.qq.com:

// Same-origin — works
fetch('https://weread.qq.com/web/book/info?bookId=855812', {credentials:'include'})
// → {title: "人类简史", ...}

// Cross-subdomain — fails
fetch('https://i.weread.qq.com/book/info?bookId=855812', {credentials:'include'})
// → {errcode: -2012}

Why ai-outline was unaffected

ai-outline.js already uses its own postWebApiWithCookies() hitting weread.qq.com/web/book/chapterInfos (same-origin), which correctly receives cookies.

Not fixed: notebooks

/user/notebooks only exists on i.weread.qq.com — there is no /web/user/notebooks equivalent (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 metadata
  • opencli weread shelf — returns shelf without fallback warning
  • opencli weread highlights 855812 — returns highlights
  • opencli weread notes 855812 — returns notes

Fixes #1709

lw-yang and others added 2 commits May 21, 2026 19:29
…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>
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.

weread/book: AUTH_REQUIRED due to using i.weread.qq.com private API instead of same-origin web API

1 participant