Skip to content

zhihu question command fails with 'Not logged in' despite valid session #604

@Gogoworks

Description

@Gogoworks

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

  1. Install Browser Bridge extension in a Chrome profile that is logged in to zhihu.com
  2. Verify opencli zhihu search "any query" works (it does)
  3. Run opencli zhihu question 2021881398772981878
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions