fix(auth): carry app_id in redirectToLogin from foreign origins - #242
fix(auth): carry app_id in redirectToLogin from foreign origins#242davidsu wants to merge 2 commits into
Conversation
From a foreign origin (local dev, where appBaseUrl is absolute) the hosted login page cannot resolve the app by Host, so redirectToLogin's bare /login?from_url=... lands on the apex with no app identity and 404s. Reuse getLoginUrl so the absolute-appBaseUrl path carries app_id; the same-origin production path (appBaseUrl === '') stays byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Claude finished @davidsu's task —— View job PR Review: carry app_id in redirectToLogin from foreign origins
Overall this is a clean, well-scoped fix. Reusing the existing Code quality — good ✅
Potential issues / things to confirm
Security — no concerns 🔒
Performance — n/aSingle synchronous string build on a user-initiated redirect. No impact. Test coverage — solid ✅
One suggested addition (non-blocking): none of the existing cases exercise a Verdict: LGTM. The one thing I'd actively verify before merge is item (1) — that the counterpart apper handler reads |
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.40-pr.242.b4656c4Prefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.40-pr.242.b4656c4"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.40-pr.242.b4656c4"
}
}
Preview published to npm registry — try new features instantly! |
|
Integration-verified end-to-end (2026-07-28, composed 4-system run: this PR's preview build + apper#17843 + cli integration branch #578+#579 + vite-plugin#100 preview):
One test-harness artifact documented along the way (host-only cookie split between 127.0.0.1/localhost in the lab setup — not a product defect, root-caused by curl reproduction). Prod apex stays expected-404 until apper#17843 merges, by design. |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Re: review feedback —
|
|
Claude finished @davidsu's task —— View job PR Review: carry app_id in redirectToLogin from foreign origins
Re-reviewed after the follow-up commits. All three items from my previous pass are now resolved — this is ready to go. Summary below. Follow-ups from prior review — all addressed ✅
Code quality — good ✅
Test coverage — solid ✅
Security — no concerns 🔒
Performance — n/aSingle synchronous string build on a user-initiated redirect. Minor observation (non-blocking)
Verdict: LGTM. Prior blockers cleared, integration-verified end-to-end, suite green. Ship it (pending the apper counterpart, as noted). View job |
Problem
redirectToLoginbuilds${appBaseUrl}/login?from_url=...with no app identity. In production (appBaseUrl === '') the relative/loginresolves the app by Host, so it works. In local dev, where the vite-plugin injects an absoluteappBaseUrl(e.g.https://base44.appfor standalonenpm run dev), the redirect lands on the apex host, which cannot resolve the app → 404 "App not found".Fix
When
appBaseUrlis a non-empty absolute origin, build the login URL with the existinggetLoginUrlutil so it carriesapp_id:When
appBaseUrl === ''(production/published/custom domains), the emitted URL stays byte-identical to today's (/login?from_url=...) — no behavior change on working paths.Cross-repo context
This is the SDK half of a two-PR feature (option A of the login-redirect decision):
/login?app_id=resolution +UserAppMainapp_id fallback + AppLoginfrom_urllocalhost carve-out. The round-trip to a local dev origin only completes once both halves land.base44 dev, the CLI dev-server/logincarve-out forwards the full query string verbatim, so the same URL serves both dev modes.loginWithProvideralready emits (verified round-tripping from localhost).Tests
appBaseUrlexpectations intests/unit/auth.test.jsandtests/unit/client.test.jsto assert the appendedapp_id.appBaseUrlabsent) is untouched and asserts the exact legacy string — the byte-identical guard.🤖 Generated with Claude Code