diff --git a/.changeset/nine-coins-pull.md b/.changeset/nine-coins-pull.md new file mode 100644 index 0000000000..ca5a724906 --- /dev/null +++ b/.changeset/nine-coins-pull.md @@ -0,0 +1,5 @@ +--- +'@directus/sdk': patch +--- + +Fixed logout SDK auth composable to include auth mode in request diff --git a/sdk/src/auth/composable.ts b/sdk/src/auth/composable.ts index 1bc0b0beb7..c1045e6b08 100644 --- a/sdk/src/auth/composable.ts +++ b/sdk/src/auth/composable.ts @@ -88,7 +88,7 @@ export const authentication = (mode: AuthenticationMode = 'cookie', config: Part fetchOptions.credentials = authConfig.credentials; } - const body: Record = { mode }; + const body: Record = { mode }; if (mode === 'json' && authData?.refresh_token) { body['refresh_token'] = authData.refresh_token; @@ -154,12 +154,14 @@ export const authentication = (mode: AuthenticationMode = 'cookie', config: Part fetchOptions.credentials = authConfig.credentials; } + const body: Record = { mode }; + if (mode === 'json' && authData?.refresh_token) { - fetchOptions.body = JSON.stringify({ - refresh_token: authData.refresh_token, - }); + body['refresh_token'] = authData.refresh_token; } + fetchOptions.body = JSON.stringify(body); + const requestUrl = getRequestUrl(client.url, '/auth/logout'); await request(requestUrl.toString(), fetchOptions, client.globals.fetch);