From d1d6a6b373861d27da0060f9739af0e5ba3f1821 Mon Sep 17 00:00:00 2001 From: Stephen Touset Date: Wed, 16 Apr 2025 09:56:27 -0700 Subject: [PATCH] Pass HTTP credentials through to the API server when appropriate CORS headers are set --- CHANGELOG.md | 1 + package.json | 2 +- src/api/services/ShlinkApiClientBuilder.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd4342f..23fa7984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * Update to `@shlinkio/shlink-js-sdk` 2.0.0 * Add `eslint-plugin-react-compiler` * Run unit tests in a headless browser using vitest browser mode and playwright. +* Existing HTTP credentials (cookies, TLS certs, authentication headers) are now automatically forwarded to the API server if appropriate [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Credentials) are set ### Deprecated * *Nothing* diff --git a/package.json b/package.json index 95bd63e2..546b8725 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@reduxjs/toolkit": "^2.6.1", "@shlinkio/data-manipulation": "^1.0.3", "@shlinkio/shlink-frontend-kit": "^0.8.10", - "@shlinkio/shlink-js-sdk": "^2.0.0", + "@shlinkio/shlink-js-sdk": "^2.0.1", "@shlinkio/shlink-web-component": "^0.13.2", "bootstrap": "5.2.3", "bottlejs": "^2.0.1", diff --git a/src/api/services/ShlinkApiClientBuilder.ts b/src/api/services/ShlinkApiClientBuilder.ts index 7b77c46f..4c1f2326 100644 --- a/src/api/services/ShlinkApiClientBuilder.ts +++ b/src/api/services/ShlinkApiClientBuilder.ts @@ -23,7 +23,7 @@ export const buildShlinkApiClient = (httpClient: HttpClient) => (getStateOrSelec : getStateOrSelectedServer; const serverKey = `${apiKey}_${baseUrl}`; - const apiClient = apiClients[serverKey] ?? new ShlinkApiClient(httpClient, { apiKey, baseUrl }); + const apiClient = apiClients[serverKey] ?? new ShlinkApiClient(httpClient, { apiKey, baseUrl }, { credentials: 'include' }); apiClients[serverKey] = apiClient; return apiClient;