Repository navigation
fix(cli): print the dashboard dev-server sign-in link on localhost - #473
Closed
surendraSinghKamboj wants to merge 2 commits into
Closed
surendraSinghKamboj wants to merge 2 commits into
surendraSinghKamboj wants to merge 2 commits into
Conversation
The sign-in cookie is host-only. The link was printed on 127.0.0.1, so the cookie was set for that site, while the Next dev dashboard on localhost:3000 calls the API as localhost. A browser treats the two as different sites, so every API call returned 401. In --dev-server mode a loopback link is now printed on localhost. Any other host is left alone. Refs blitzcrieg1#301
CodeQL flagged the startswith() on a URL as incomplete URL substring sanitization. Parse the link and assert scheme, host and port.
Owner
|
Landed as rebased PR #474 after #472 (conflicts in CHANGELOG/README/test file resolved, README recounted to 2980 tests). Thanks @surendraSinghKamboj. |
blitzcrieg1
added a commit
that referenced
this pull request
Nov 25, 2026
… refs #301) (#474) * test(cli): compare the parsed host instead of a URL prefix CodeQL flagged the startswith() on a URL as incomplete URL substring sanitization. Parse the link and assert scheme, host and port. * fix(cli): print the dashboard dev-server sign-in link on localhost The sign-in cookie is host-only. The link was printed on 127.0.0.1, so the cookie was set for that site, while the Next dev dashboard on localhost:3000 calls the API as localhost. A browser treats the two as different sites, so every API call returned 401. In --dev-server mode a loopback link is now printed on localhost. Any other host is left alone. Refs #301 --------- Co-authored-by: Surendra Singh Kamboj <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Refs #301.
agentmetry dashboard --dev-serverprinted the sign-in link on127.0.0.1. The cookie is host-only, so it was set for that site. The redirect then landed onlocalhost:3000, and the dev dashboard calls the API aslocalhost:8000. A browser treats127.0.0.1andlocalhostas different sites, so the cookie was never sent and every API call returned 401.This takes the first fix option from the issue: in
--dev-servermode a loopback sign-in link is printed (and opened) onlocalhost. Only the IPv4 loopback literal is rewritten. A customAGENTMETRY_URLhost is left alone, and without--dev-servernothing changes.Not in this PR
The issue also asks the page to say "not signed in" on a 401 instead of waiting on "Checking sign-in...". That is a dashboard change, so I left it for a separate PR rather than mix a CLI fix with front-end work.
Checks
tests/test_cli_commands.py(dev-server link on localhost, link unchanged without the flag, other hosts untouched). The first fails onmasterand passes with the change.python -m pytest -q: 2959 passed, 19 skippedpython -m ruff check agentmetry testspasses