Repository navigation
BFF: Treat baseUrl config as the BFF's base URL - #149
Merged
Merged
Conversation
In backend mode (endpoints.backend) the top-level baseUrl is now the backend, the BFF. It defaults to the page's origin. Every endpoint in endpoints.backend given as a path is resolved against it, and an absolute URL is used as it is, so pointing an app at a BFF is one setting. The API behind the proxy moves to the new endpoints.backend.apiBaseUrl, which defaults to baseUrl. Requests under it are sent through the proxy, and the SDK builds its own API requests on it (resolveApiBaseUrl). That covers the browser client's and the Vue client's /users/me, and the baseUrl the React and Vue providers put in their context, which the account and management components and hooks build their URLs on. The client itself is still initialized with the real baseUrl. Backend requests send cookies with credentials 'include', so a BFF on another origin works when its CORS allows it, though RFC 10017 recommends the app's own origin. OIDC discovery is skipped in backend mode unless endpoints.wellKnown is set, since the backend runs OAuth itself. Signed-off-by: Brion <info@brionmario.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
🔀 Cross-SDK feature parity, ports raisedThis pull request is labelled Ports (DO NOT EDIT)
3 of 3 sibling SDKs accounted for. Every sibling SDK is accounted for. The contract is in the SDK development specification. |
rajithacharith
approved these changes
Oct 30, 2026
baseUrl config as the BFF's base URL
brionmario
added a commit
to brionmario/thunderid
that referenced
this pull request
Oct 30, 2026
Moves @thunderid/react to 1.11.2 and @thunderid/react-router to 1.10.2, which bring @thunderid/browser 1.9.2 and @thunderid/javascript 1.10.2. They include two backend-mode (endpoints.backend) changes: - thunder-id/javascript-sdks#148: useGrantedPermissions reads the granted permissions from the backend's session (scope) instead of decoding an access token. A console signed in through a backend (BFF) then shows the pages its permissions allow, instead of "Nothing to manage". - thunder-id/javascript-sdks#149: the top-level baseUrl is the backend, endpoint paths resolve against it, and the API behind the proxy is endpoints.backend.apiBaseUrl. Neither changes redirect mode, which the consoles use by default. Signed-off-by: Brion <info@brionmario.com>
This was referenced Oct 30, 2026
Merged
brionmario
added a commit
to brionmario/thunderid
that referenced
this pull request
Oct 30, 2026
Moves @thunderid/react to 1.11.3 and @thunderid/react-router to 1.10.3, which bring @thunderid/browser 1.9.3 and @thunderid/javascript 1.10.3. They include three backend-mode (endpoints.backend) changes: - thunder-id/javascript-sdks#148: useGrantedPermissions reads the granted permissions from the backend's session (scope) instead of decoding an access token. A console signed in through a backend (BFF) then shows the pages its permissions allow, instead of "Nothing to manage". - thunder-id/javascript-sdks#149: the top-level baseUrl is the backend, and endpoint paths resolve against it. - thunder-id/javascript-sdks#150: the SDK's API calls go to the backend's proxy (baseUrl + proxy), so the frontend never needs the API's own address; the backend maps the proxy to it. None of them changes redirect mode, which the consoles use by default. Signed-off-by: Brion <info@brionmario.com>
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.
Purpose
In backend mode (
endpoints.backend) every backend endpoint had to be spelled out on its own, and the top-levelbaseUrlmeant the API behind the proxy, so pointing an app at its backend for frontend (BFF) took several settings and read the wrong way round. NowbaseUrlis the BFF, and the endpoints are resolved against it.Approach
baseUrlis the backend. It's optional and defaults to the page's origin.endpoints.backend(signIn,session,checkSession,refresh,signOut,proxy,token) given as a path is resolved againstbaseUrl; an absolute URL is used as it is. The defaults stay/api/auth/..., so they resolve underbaseUrl. WithoutbaseUrlthe paths stay relative to the page.endpoints.backend.apiBaseUrl: the API behind the proxy. Requests under it go throughproxy. It defaults tobaseUrl, then the page's origin.resolveApiBaseUrl(config)gives the base the SDK builds its own API requests on:apiBaseUrlin backend mode (falling back tobaseUrl),baseUrlotherwise. It's used by:ThunderIDBrowserClient.getUserProfile()(/users/me);ThunderIDVueClient.getUser()andgetUserProfile();baseUrlthey put in their context, which the account and management components and hooks build their URLs on, and for the organization path. The client itself is still initialized with the realbaseUrl.credentials: 'include', so a BFF on another origin works when its CORS allows credentials. RFC 10017 recommends the app's own origin, and the doc comments say so.endpoints.wellKnownis set: the backend runs OAuth, so there's nothing to discover atbaseUrl.endpoints.backend.Related Issues
Related PRs
SDK parity
The mobile SDKs get the same change: in backend mode the top-level
baseUrlis the backend, with the API underendpoints.backend.apiBaseUrl.Checklist
BackendEndpoints,apiBaseUrlandresolveApiBaseUrldoc comments describe the change; no Markdown docs cover backend mode.resolveBackendEndpoints.test.ts,BackendClient.test.ts,ThunderIDBrowserClient.backend.test.ts,ThunderIDProvider.test.tsx)breaking changelabel added.parity/prs-raisedorparity/prs-not-neededadded.parity/prs-raised, the port links are posted as a reply on the parity check's comment.Security checks