[FRONT COMPONENTS] Retrieve the front components from the backend (#17813)

- Pass the auth token to worker
- Fetch the file from the rest API with the auth token
- Create the blob url
- Update the stories to pass a fake token which will be ignored

---------

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Raphaël Bosi
2026-02-09 19:10:29 +01:00
committed by GitHub
parent 37b9a55382
commit f51291704d
7 changed files with 47 additions and 54 deletions
@@ -1,4 +1,5 @@
import { getMockFrontComponentUrl } from '@/front-components/utils/mockFrontComponent';
import { REST_API_BASE_URL } from '@/apollo/constant/rest-api-base-url';
import { getTokenPair } from '@/apollo/utils/getTokenPair';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useTheme } from '@emotion/react';
import { t } from '@lingui/core/macro';
@@ -13,7 +14,7 @@ type FrontComponentRendererProps = {
};
export const FrontComponentRenderer = ({
frontComponentId: _frontComponentId,
frontComponentId,
}: FrontComponentRendererProps) => {
const theme = useTheme();
const [hasError, setHasError] = useState(false);
@@ -22,6 +23,9 @@ export const FrontComponentRenderer = ({
const { executionContext, frontComponentHostCommunicationApi } =
useFrontComponentExecutionContext();
const componentUrl = `${REST_API_BASE_URL}/front-components/${frontComponentId}`;
const authToken = getTokenPair()?.accessOrWorkspaceAgnosticToken?.token;
const handleError = (error?: Error) => {
if (isDefined(error)) {
const errorMessage = error.message;
@@ -33,14 +37,16 @@ export const FrontComponentRenderer = ({
setHasError(true);
};
if (hasError) {
if (hasError || !isDefined(authToken)) {
// TODO: Add an error display component here
return null;
}
return (
<SharedFrontComponentRenderer
theme={theme}
componentUrl={getMockFrontComponentUrl()}
componentUrl={componentUrl}
authToken={authToken}
executionContext={executionContext}
frontComponentHostCommunicationApi={frontComponentHostCommunicationApi}
onError={handleError}