From 614c9e4481f5a0e436802060204f80c0e80942fa Mon Sep 17 00:00:00 2001 From: Doxterpepper Date: Tue, 13 Aug 2024 11:53:19 -0400 Subject: [PATCH] Backport pull request #5730 from jellyfin-web/release-10.9.z Add no-cache attribute for fetch requests to /system/info/public to prevent stale server info Original-merge: a0e6da790c3f40185eb970836d38569cab2fd047 Merged-by: thornbill Backported-by: thornbill --- src/components/ConnectionRequired.tsx | 2 +- src/components/router/appRouter.js | 2 +- src/hooks/useSystemInfo.ts | 2 +- src/utils/dashboard.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ConnectionRequired.tsx b/src/components/ConnectionRequired.tsx index 8dde8ec1e7..ad2577c5d1 100644 --- a/src/components/ConnectionRequired.tsx +++ b/src/components/ConnectionRequired.tsx @@ -83,7 +83,7 @@ const ConnectionRequired: FunctionComponent = ({ if (firstConnection.State === ConnectionState.ServerSignIn) { // Verify the wizard is complete try { - const infoResponse = await fetch(`${firstConnection.ApiClient.serverAddress()}/System/Info/Public`); + const infoResponse = await fetch(`${firstConnection.ApiClient.serverAddress()}/System/Info/Public`, { cache: 'no-cache' }); if (!infoResponse.ok) { throw new Error('Public system info request failed'); } diff --git a/src/components/router/appRouter.js b/src/components/router/appRouter.js index 20571c840f..31e949035d 100644 --- a/src/components/router/appRouter.js +++ b/src/components/router/appRouter.js @@ -387,7 +387,7 @@ class AppRouter { if (firstResult) { if (firstResult.State === ConnectionState.ServerSignIn) { const url = firstResult.ApiClient.serverAddress() + '/System/Info/Public'; - fetch(url).then(response => { + fetch(url, { cache: 'no-cache' }).then(response => { if (!response.ok) return Promise.reject(new Error('fetch failed')); return response.json(); }).then(data => { diff --git a/src/hooks/useSystemInfo.ts b/src/hooks/useSystemInfo.ts index 9fed3dd3f6..0fa4604a59 100644 --- a/src/hooks/useSystemInfo.ts +++ b/src/hooks/useSystemInfo.ts @@ -23,7 +23,7 @@ export const getSystemInfoQuery = ( api?: Api ) => queryOptions({ queryKey: [ 'SystemInfo' ], - queryFn: ({ signal }) => fetchSystemInfo(api, { signal }), + queryFn: ({ signal }) => fetchSystemInfo(api, { signal, headers: { 'Cache-Control': 'no-cache' } }), // Allow for query reuse in legacy javascript. staleTime: 1000, // 1 second enabled: !!api diff --git a/src/utils/dashboard.js b/src/utils/dashboard.js index 393125c6fd..89c4c406d6 100644 --- a/src/utils/dashboard.js +++ b/src/utils/dashboard.js @@ -52,7 +52,7 @@ export async function serverAddress() { console.debug('URL candidates:', urls); const promises = urls.map(url => { - return fetch(`${url}/System/Info/Public`) + return fetch(`${url}/System/Info/Public`, { cache: 'no-cache' }) .then(async resp => { if (!resp.ok) { return;