Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyway to pass cookies for the web tool? #33

Open
junaid33 opened this issue Feb 12, 2025 · 3 comments
Open

Anyway to pass cookies for the web tool? #33

junaid33 opened this issue Feb 12, 2025 · 3 comments

Comments

@junaid33
Copy link

First off, thank you for this amazing tool and it's a game changer. I'm trying to use the new chrome debug using stagehand but our dashboard pages are protected so when we try to access like localhost:3000/dashboard/products, we are redirected to localhost:3000/dashboard/signin.

Using playwright directly, I can set the cookie we need and see the page perfectly:

npx node -e 'const { chromium } = require("playwright"); (async () => { 
  const browser = await chromium.launch({ headless: false }); 
  const context = await browser.newContext(); 
  await context.addCookies([{ 
    name: "session", 
    value: "Fe26.2**", 
    domain: "localhost", 
    path: "/" 
  }]); 
  const page = await context.newPage(); 
  await page.goto("http://localhost:3000/dashboard", { waitUntil: "networkidle" }); 
  console.log(await context.cookies()); 
  await page.waitForTimeout(60000); 
  await browser.close(); 
})();'

Can we pass a cookie to cursor tools and have it pass that to stagehand? Is there a better way to handle it? I've also looked into tweaking my cursorrules file to use playwright directly if cookies are passed and cursor-tools web if not.

@eastlondoner
Copy link
Owner

Great issue!

For now if you do it in connected mode you can set the cookie through regular dev tools - DM me on Twitter if you want a demonstration.

@junaid33
Copy link
Author

junaid33 commented Feb 12, 2025

Wow got it! Here are instructions for others to follow:

  1. open -a "Google Chrome" --args --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir="/tmp/chrome-remote-debugging"

This cli command opens the Chrome browser. Go into inspect element > application and set the cookies manually.

  1. npx cursor-tools browser open "http://localhost:3000/dashboard" --connect-to=9222

This command lets cursor tools know to connect to the already open browser which has the cookie now and should render

  1. Be sure to tell Composer agent to use this port for connect to arg

@eastlondoner
Copy link
Owner

@junaid33 lets go! Nice work.

Let us know how it goes for you - please share back how you’re using it, what works and what doesn’t

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

No branches or pull requests

2 participants