From 87649a06bfc38d39646117f4e5f80cd3ddf9d724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 15 Aug 2022 13:14:03 +0200 Subject: [PATCH] Add note about fetchApi not being suitable for sign-in page use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/sweet-apricots-kneel.md | 5 +++++ packages/core-plugin-api/src/apis/definitions/FetchApi.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/sweet-apricots-kneel.md diff --git a/.changeset/sweet-apricots-kneel.md b/.changeset/sweet-apricots-kneel.md new file mode 100644 index 0000000000..1a114ec4ae --- /dev/null +++ b/.changeset/sweet-apricots-kneel.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-plugin-api': patch +--- + +Add a note that the `fetchApi` utility should not be used on sign-in page implementations and similar. diff --git a/packages/core-plugin-api/src/apis/definitions/FetchApi.ts b/packages/core-plugin-api/src/apis/definitions/FetchApi.ts index b1a4dbbd0b..aba0e53bb7 100644 --- a/packages/core-plugin-api/src/apis/definitions/FetchApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/FetchApi.ts @@ -37,6 +37,13 @@ export type FetchApi = { * This is a wrapper for the fetch API, that has additional behaviors such as * the ability to automatically inject auth information where necessary. * + * Note that the default behavior of this API (unless overridden by your org), + * is to require that the user is already signed in so that it has auth + * information to inject. Therefore, using the default implementation of this + * utility API e.g. on the `SignInPage` or similar, would cause issues. In + * special circumstances like those, you can use the regular system `fetch` + * instead. + * * @public */ export const fetchApiRef: ApiRef = createApiRef({