-
Notifications
You must be signed in to change notification settings - Fork 764
Description
Bug Description
opencli zhihu question <id> always fails with 🔒 Not logged in to www.zhihu.com, even when the user is logged in to Zhihu in the browser profile where the Browser Bridge extension is installed.
Other Zhihu commands (e.g. zhihu search) work correctly with the same login session.
Environment
- opencli: v1.5.6
- Extension: v1.5.5
- OS: macOS (Darwin 25.4.0)
- Node: v22.22.1
Steps to Reproduce
- Install Browser Bridge extension in a Chrome profile that is logged in to zhihu.com
- Verify
opencli zhihu search "any query"works (it does) - Run
opencli zhihu question 2021881398772981878 - Result:
🔒 Not logged in to www.zhihu.com
Root Cause
In src/clis/zhihu/question.ts, the command calls page.evaluate() with fetch(..., {credentials: 'include'}) directly, without first navigating to the Zhihu domain. Since the browser context is not on www.zhihu.com, cookies are not attached to the fetch request, and the Zhihu API returns an auth error.
In contrast, src/clis/zhihu/search.yaml includes a navigate: https://www.zhihu.com step before the evaluate, which establishes the correct domain context for cookies to be sent.
Suggested Fix
Add a navigation step in question.ts before the page.evaluate() call:
await page.goto('https://www.zhihu.com');This matches the pattern used in search.yaml and should allow credentials: 'include' to work correctly.