Skip to content

Accept the null Origin in CLI browser login loopback - #1520

Merged
helpcodeai merged 1 commit into
mainfrom
fix/cli-browser-login-null-origin
Nov 4, 2026
Merged

helpcodeai merged 1 commit into
mainfrom
fix/cli-browser-login-null-origin

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

amcp login --browser --url https://cloud.anythingmcp.com never completed: after Authorize, the loopback page showed "Unexpected origin. Nothing was saved."

Cause: Chrome sends Origin: null when an HTTPS page (the /cli-auth dashboard page) posts a form to the http://127.0.0.1 loopback, a secure-to-insecure navigation. Verified with a probe server: the request arrived with origin: "null" and sec-fetch-site: cross-site. The CLI accepted only the exact instance origin, so it rejected every Cloud (HTTPS) login.

Fix: the loopback server also accepts the opaque null origin. It still refuses a POST that names any other origin. The 192-bit state stays the check that binds the browser POST to this CLI run. The CLI version goes to 0.1.2, so the fix can be published.

Deployment modes

  • Cloud: browser login now works.
  • Self-hosted over HTTPS: same fix. Self-hosted over plain HTTP already worked, because the browser sends the real origin.
  • No backend or frontend change.

Tests

  • packages/cli: npm test. Result: 21 passed, 2 skipped (fish is not installed), 0 failed. New cases: a POST with Origin: null delivers the key, and a foreign-origin POST gets 403 without ending the login.
  • Manual end-to-end test against production with the local build: XDG_CONFIG_HOME=<tmp> AMCP_NO_BROWSER=1 node dist/index.js login --browser --url https://cloud.anythingmcp.com, then Authorize in Chrome. Result: "Logged in to https://cloud.anythingmcp.com (management, profile: default)", and amcp api GET /api/users/me returned the user.

Browsers send Origin: null when an HTTPS dashboard page posts a form to
the http://127.0.0.1 loopback, so amcp login --browser always answered
'Unexpected origin' against Cloud. Accept null, keep refusing any other
foreign origin; the 192-bit state remains the binding check. Bump the
CLI to 0.1.2.
@helpcodeai
helpcodeai merged commit baca412 into main Nov 4, 2026
15 checks passed
@helpcodeai
helpcodeai deleted the fix/cli-browser-login-null-origin branch November 4, 2026 20:43
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant