feat(web): serve the CLI login flow from the apex - #106
Merged
Conversation
`logicsrc login` defaults to https://logicsrc.com (#104), but every path it needs returns 404 there: the apex runs the marketing app, while /cli/* lives in apps/pwa on its own service. Proxy those paths from the app that owns the apex, the same way CommandBoard is already proxied. No DNS record, no Railway custom domain, and no subdomain -- and it makes the CLI's existing default origin correct rather than requiring another change to chase it. Pointing the apex at the pwa instead was the obvious alternative and is wrong: the pwa serves `/` too, so it would take the marketing site down with it. Proxied: /cli/:path* the device-code and loopback login flows /api/me identity /api/credshare/:path* the credential-sharing API used after login /auth/:path* /cli/authorize and /cli/device are behind requireAuth, so an unauthenticated visitor is redirected here; without it the browser half of the flow dead-ends on a 404 Order matters and is asserted: CommandBoard owns a catch-all /api/:path*, so /api/me and /api/credshare/* have to match first or CLI auth silently goes to the wrong service. Rewrite construction is factored into pure functions so the ordering is testable without booting Next, and degrades cleanly: with CREDENTIALS_APP_URL unset the output is byte-identical to what shipped before. Requires CREDENTIALS_APP_URL on the logicsrc-web service, pointing at the credentials app's origin. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
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.
logicsrc logindefaults tohttps://logicsrc.com(#104) — but every path it needs 404sthere. The apex runs the marketing app;
/cli/*lives inapps/pwaon a separate service.This fixes it with no DNS record, no subdomain, and no Railway custom domain. The app
that owns the apex proxies those paths, exactly as it already proxies CommandBoard.
Pointing the apex at the pwa was the obvious alternative and is wrong: the pwa serves
/too, so it would take the marketing site down with it.
Proxied
/cli/:path*/api/me/api/credshare/:path*/auth/:path*/cli/authorizeand/cli/deviceare behindrequireAuth, so an unauthenticated visitor gets redirected here — without it the browser half of login dead-ends on a 404Ordering is the subtle part
CommandBoard owns a catch-all
/api/:path*. Anything of the credentials app's under/apimust match first, or CLI auth silently goes to the wrong service. Verified:Verified
Rewrite construction is factored into pure functions so ordering is testable without
booting Next. All checks pass, including that with
CREDENTIALS_APP_URLunset the outputis byte-identical to what ships today — this is additive, not a behaviour change for
the existing deployment.
A vitest contract test is included; it couldn't be executed here (no
node_modulesin theenvironment), so the logic was verified by loading the config directly under Node.
Deploy
Set
CREDENTIALS_APP_URLon the logicsrc-web service to the credentials app's origin.Until that's set, nothing changes.
🤖 Generated with Claude Code