fix(dev): accept prod-minted sessions and keep logout on localhost - #579
Open
davidsu wants to merge 1 commit into
Open
fix(dev): accept prod-minted sessions and keep logout on localhost#579davidsu wants to merge 1 commit into
davidsu wants to merge 1 commit into
Conversation
Two auth gaps found in the local-dev browser test matrix: - A valid token whose subject never registered locally (e.g. a Google OAuth round-trip minted by production) 404'd on User/me and left the app stuck logged out. The dev server now creates a local user record on first sight of such a subject. - /api/apps/auth/logout fell through the auth carve-out to production, which drops localhost from_url targets and stranded the browser on base44.com. The dev server now answers logout locally and redirects back to localhost from_url targets only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.6-pr.579.8e3e3daPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.6-pr.579.8e3e3da"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.6-pr.579.8e3e3da"
}
}
Preview published to npm registry — try new features instantly! |
This was referenced Jul 29, 2026
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.
Note
Description
Fixes two auth gaps in the
base44 devlocal server that left cli-created apps stuck in a broken login loop. First, a token minted by production (e.g. after a Google OAuth round-trip) was rejected locally becauseresolveCurrentUseronly knew about users created through local OTP signup, soUser/mereturned 404 and the app stayed logged out despite holding a valid token. Second, the SDK’slogout()navigates to/api/apps/auth/logout?from_url=<app>, which the dev server bounced to production — prod rejects foreignfrom_urltargets and redirects to its own host, stranding the browser on base44.com.Related Issue
None
Type of Change
Changes Made
routes/entities/current-user.ts— when a valid token carries a subject with no local user record, create one on first sight (via a newcreateLocalUserhelper) instead of returningnot_found. The inserted document mirrors the shape written by the OTP registration path (id,email,full_name,is_service,is_verified,disabled,role,collaborator_role, timestamps), so subsequent requests resolve the same stable user.main.ts— handleGET /api/apps/auth/logoutlocally, registered before the existing/api/apps/auth/*redirect carve-out. A newisLocalRedirectTarget()guard only honoursfrom_urlvalues onhttp(s)://localhostor127.0.0.1; anything else falls through to a plainLogged outresponse rather than becoming an open redirect.utils.ts— extractderiveFullNameFromEmail()and reuse it from bothauth-router.ts(OTP registration) and the new local-user creation path, removing the duplicated regex.tests/cli/dev-auth.spec.ts— hoistserverUrlto suite scope and add three cases: a prod-minted token yields a working session with a stable id across calls, logout 302s back to a localhostfrom_url, and a foreign origin is not used as a redirect target.CHANGELOG.md— two entries under Fixed describing both behaviours.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
The logout route is intentionally answered locally rather than loosening production’s
from_urlsanitisation, which is a shared security control — local sessions are client-side JWTs the SDK has already cleared, so there is no server-side session to tear down. Note thatresolveCurrentUserdecodes rather than verifies the JWT, so the create-on-first-sight path trusts any well-formed token subject; that is consistent with the existing dev-server behaviour and acceptable for a localhost-only development server, but it means the dev user store can accumulate records for arbitrary subjects.🤖 Generated by Claude | 2026-07-28 13:50 UTC | 8e3e3da