Pass HTTP credentials through to the API server when appropriate CORS headers are set

This commit is contained in:
Stephen Touset 2025-04-16 09:56:27 -07:00 committed by Alejandro Celaya
parent c1bbeeb6ac
commit d1d6a6b373
3 changed files with 3 additions and 2 deletions

View File

@ -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 * Update to `@shlinkio/shlink-js-sdk` 2.0.0
* Add `eslint-plugin-react-compiler` * Add `eslint-plugin-react-compiler`
* Run unit tests in a headless browser using vitest browser mode and playwright. * 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 ### Deprecated
* *Nothing* * *Nothing*

View File

@ -30,7 +30,7 @@
"@reduxjs/toolkit": "^2.6.1", "@reduxjs/toolkit": "^2.6.1",
"@shlinkio/data-manipulation": "^1.0.3", "@shlinkio/data-manipulation": "^1.0.3",
"@shlinkio/shlink-frontend-kit": "^0.8.10", "@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", "@shlinkio/shlink-web-component": "^0.13.2",
"bootstrap": "5.2.3", "bootstrap": "5.2.3",
"bottlejs": "^2.0.1", "bottlejs": "^2.0.1",

View File

@ -23,7 +23,7 @@ export const buildShlinkApiClient = (httpClient: HttpClient) => (getStateOrSelec
: getStateOrSelectedServer; : getStateOrSelectedServer;
const serverKey = `${apiKey}_${baseUrl}`; 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; apiClients[serverKey] = apiClient;
return apiClient; return apiClient;