jackwener/OpenCLI · error

Redirected away from creator center — session may have expir

Error message

Redirected away from creator center — session may have expired. Re-capture browser login via: opencli xiaohongshu creator-profile

What it means

Thrown during the first step of the xiaohongshu publish automation after page.goto(PUBLISH_URL). The CLI checks location.href and expects it to contain creator.xiaohongshu.com; if the site redirected elsewhere (typically the login page), the stored browser session is considered dead, so publishing cannot proceed.

Source

Thrown at clis/xiaohongshu/publish.js:1220

            throw new ArgumentError(`Title is ${title.length} chars — must be ≤ ${MAX_TITLE_LEN}`);
        if (!content)
            throw new ArgumentError('Positional argument <content> is required');
        if (!isTextImage && imagePaths.length === 0)
            throw new ArgumentError('Provide --card-text (text-image mode) or --images (upload mode); neither was given.');
        if (imagePaths.length > MAX_IMAGES)
            throw new ArgumentError(`Too many images: ${imagePaths.length} (max ${MAX_IMAGES})`);
        // The editor-page image input (text-image append) rejects gif.
        if (isTextImage && imagePaths.some((p) => path.extname(p).toLowerCase() === '.gif'))
            throw new ArgumentError('文字配图模式追加的图片不支持 .gif(编辑器图片入口只接受 jpg/jpeg/png/webp)');
        // Validate image paths before navigating (fast-fail on bad paths / unsupported formats)
        const absImagePaths = validateImagePaths(imagePaths);
        // ── Step 1: Navigate to publish page ──────────────────────────────────────
        await page.goto(PUBLISH_URL);
        await page.wait({ time: 3 });
        // Verify we landed on the creator site (not redirected to login)
        const pageUrl = await page.evaluate('() => location.href');
        if (!pageUrl.includes('creator.xiaohongshu.com')) {
            throw new Error('Redirected away from creator center — session may have expired. ' +
                'Re-capture browser login via: opencli xiaohongshu creator-profile');
        }
        // ── Step 2: Select 图文 (image+text) note type if tabs are present ─────────
        const tabResult = await selectImageTextTab(page);
        const surface = await waitForPublishSurfaceState(page, tabResult?.ok ? 5_000 : 2_000);
        if (surface.state === 'video_surface') {
            await page.screenshot({ path: '/tmp/xhs_publish_tab_debug.png' });
            const detail = tabResult?.ok
                ? `clicked "${tabResult.text}"`
                : `visible candidates: ${(tabResult?.visibleTexts || []).join(' | ') || 'none'}`;
            throw new Error('Still on the video publish page after trying to select 图文. ' +
                `Details: ${detail}. Debug screenshot: /tmp/xhs_publish_tab_debug.png`);
        }
        // ── Step 3: Acquire images — text-image generation and/or upload ──────────
        let appliedCardStyle = cardStyle;
        if (isTextImage) {
            // Drive 文字配图: type cards → 生成图片 → pick style → 下一步 → standard editor.
            appliedCardStyle = await runTextImageFlow(page, cards, cardStyle);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run 'opencli xiaohongshu creator-profile' to re-capture an interactive browser login, then retry publish.
  2. Verify network/proxy settings are not blocking creator.xiaohongshu.com.
  3. Log in manually in a normal browser to clear any security verification/captcha on the account, then re-capture.
  4. Wait and retry later if xiaohongshu is rate-limiting or challenging the account.

Example fix

// before
opencli xiaohongshu publish --title "hi" --images a.png
// after
opencli xiaohongshu creator-profile   # re-capture login first
opencli xiaohongshu publish --title "hi" --images a.png
Defensive patterns

Strategy: retry

Validate before calling

// before publishing, verify the captured profile is still valid
const url = await page.evaluate('() => location.href');
if (!url.includes('creator.xiaohongshu.com')) {
  console.error('Session dead — run: opencli xiaohongshu creator-profile');
  process.exit(1);
}

Type guard

function isCreatorUrl(url) {
  return typeof url === 'string' && url.includes('creator.xiaohongshu.com');
}

Try / catch

try {
  await publish(opts);
} catch (e) {
  if (String(e.message).includes('session may have expired')) {
    execSync('opencli xiaohongshu creator-profile');
    return publish(opts); // retry once after re-login
  }
  throw e;
}

Prevention

When it happens

Trigger: Navigating to the publish URL lands on a non-creator host (login wall, verify page, or redirect to www.xiaohongshu.com) because the persisted browser login is missing or expired.

Common situations: Expired xiaohongshu session cookies, running the publish command on a machine/profile where 'opencli xiaohongshu creator-profile' was never run, xiaohongshu forcing re-authentication or captcha, or a proxy/network change invalidating the session.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2eb5bbe20fd18769. Report an issue: GitHub.