Repository navigation
BFF: send API calls through the backend's proxy, and drop apiBaseUrl - #150
Merged
Merged
Conversation
In backend mode the backend maps its proxy to the API from its own configuration, so the app doesn't need the API's address. endpoints.backend.apiBaseUrl and resolveApiBaseUrl() are removed. - The SDK builds its own API requests, such as /users/me and the management APIs, on the backend's proxy, resolved against baseUrl: resolveRequestBaseUrl() returns it in backend mode, and baseUrl otherwise. The React and Vue context baseUrl, which the account and management hooks build on, follows it. - BackendClient.toProxyUrl sends a URL already on the proxy as it is, as a path or a full URL, with no second prefix. Any other path goes under the proxy, and any other absolute URL is refused. The bypass is unchanged. 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. |
This was referenced Oct 30, 2026
Merged
thiva-k
approved these changes
Oct 30, 2026
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>
3 of 12 tasks
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) the backend is the one that knows where the API is: it maps its proxy to the API from its own configuration and attaches the token. #149 still made the app name the API's address inendpoints.backend.apiBaseUrl, so the SDK could recognise absolute API URLs and rewrite them to the proxy. That puts a server-side detail in the frontend's config. With this change the frontend only knowsbaseUrl(the backend) andproxy.Approach
apiBaseUrl:endpoints.backend.apiBaseUrlandresolveApiBaseUrl()are removed./users/me,/users/me/meta, the management APIs) are built on the backend's proxy, resolved againstbaseUrl:${baseUrl}${proxy}/users. The newresolveRequestBaseUrl()returns that base in backend mode, andbaseUrlotherwise. The React and Vue contextbaseUrl, which the account and management hooks build on, follows it.endpointsoverrides still win.BackendClient.toProxyUrl:/users) goes under the proxy;Related Issues
Related PRs
baseUrlconfig as the BFF's base URL #149: madebaseUrlthe backend and addedapiBaseUrl, which this removes.Checklist
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