This repository was archived by the owner on Jun 9, 2026. It is now read-only.
fix: auto-trust private/LAN IPs for Better Auth origin validation (#312) - #320
Open
MarlBurroW wants to merge 1 commit into
Open
fix: auto-trust private/LAN IPs for Better Auth origin validation (#312)#320MarlBurroW wants to merge 1 commit into
MarlBurroW wants to merge 1 commit into
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Fixes the "Invalid origin" error that prevents login when accessing KinBot from a LAN IP address (e.g.
http://192.168.178.43:3000), which is a common scenario for Docker users on NAS devices and home servers.Root cause
Better Auth validates the
Originheader of incoming requests against a configuredtrustedOriginslist. Previously, this list only included:config.publicUrl(defaults tohttp://localhost:3333)localhost/127.0.0.1entries on ports 5173, 5174, 3000When a user accesses KinBot via their NAS/server's LAN IP (e.g.
http://192.168.178.43:3000), the origin doesn't match any trusted origin, causingERROR [Better Auth]: Invalid origin: http://192.168.178.43:3000.Fix
When
TRUSTED_ORIGINSis not explicitly set, we now use a dynamic function (supported by Better Auth) that:publicUrl+ dev servers)10.x.x.x,172.16-31.x.x,192.168.x.x), loopback (127.x.x.x,::1), link-local (169.254.x.x,fe80::,fd..), andlocalhostThis is safe because KinBot is a self-hosted tool and private network origins should always be trusted. Users who set
TRUSTED_ORIGINSexplicitly still get the exact list they configured (no behavior change).Changes
src/server/auth/index.ts: AddedisPrivateHost()helper andbuildTrustedOrigins()function that dynamically trusts private IPsdocker/docker-compose.yml: Improved comments aboutPUBLIC_URLto clarify that LAN IPs are auto-trusted for authCloses #312
Type of Change
How to Test
PUBLIC_URLorTRUSTED_ORIGINShttp://192.168.x.x:3000)Checklist