mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-27 16:53:02 -05:00
2.0 KiB
2.0 KiB
better-auth, @better-auth/oauth-provider
| better-auth | @better-auth/oauth-provider |
|---|---|
| patch | patch |
harden dynamic baseURL handling for direct auth.api.* calls and plugin metadata helpers
Direct auth.api.* calls
- Throw
APIErrorwith a clear message when the baseURL can't be resolved (no source and nofallback), instead of leavingctx.context.baseURL = ""for downstream plugins to crash on. - Convert
allowedHostsmismatches on the direct-API path toAPIError. - Honor
advanced.trustedProxyHeaderson the dynamic path (defaulttrue, unchanged). Previouslyx-forwarded-host/-protowere unconditionally trusted withallowedHosts; they now go through the same gate as the static path. The default flip tofalseships in a follow-up PR. resolveRequestContextrehydratestrustedProvidersand cookies per call (in addition totrustedOrigins). User-definedtrustedOrigins(req)/trustedProviders(req)callbacks receive aRequestsynthesized from forwarded headers when no fullRequestis available.- Infer
httpfor loopback hosts (localhost,127.0.0.1,[::1],0.0.0.0) on the headers-only protocol fallback, so local-dev calls don't silently resolve tohttps://localhost:3000. hasRequestusesisRequestLike, which now rejects objects that spoofSymbol.toStringTagwithout a realurl/headers.getshape.
Plugin metadata helpers
oauthProviderAuthServerMetadata,oauthProviderOpenIdConfigMetadata,oAuthDiscoveryMetadata, andoAuthProtectedResourceMetadataforward the incoming request to their chainedauth.apicalls, soissuerand discovery URLs reflect the request host on dynamic configs.withMcpAuthforwards the incoming request togetMcpSession, threadstrustedProxyHeaders, and emits a bareBearerchallenge whenbaseURLcan't be resolved (instead ofBearer resource_metadata="undefined/...").metadataResponsein@better-auth/oauth-providernormalizes headers vianew Headers()so callers can passHeaders, tuple arrays, or records without silently dropping entries.