From fc4f396808095d093bf31aebc603d95033b8b48c Mon Sep 17 00:00:00 2001 From: Dock O'Neal Date: Mon, 24 Jun 2024 17:01:55 -0400 Subject: [PATCH 1/2] Changing System/Info/Public to no-cache. Prevents from identifying the correct server version during upgrade --- src/components/ConnectionRequired.tsx | 2 +- src/components/router/appRouter.js | 2 +- src/utils/dashboard.js | 2 +- 3 files changed, 3 insertions(+), 3 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 50ab0a6121..896c1ab166 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('fetch failed'); return response.json(); }).then(data => { 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; From f1ecb967bfd0580fec8b6d601a00f32c1c0438a5 Mon Sep 17 00:00:00 2001 From: Dock O'Neal Date: Sat, 3 Aug 2024 20:56:54 -0400 Subject: [PATCH 2/2] adding no-cache Cache-Control header policy. Adding no-cache Cache-Control header policy to prevent caching of server version. This ensures the correct server version is always retrieved. --- src/hooks/useSystemInfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useSystemInfo.ts b/src/hooks/useSystemInfo.ts index fda74f1439..83e5b58cf2 100644 --- a/src/hooks/useSystemInfo.ts +++ b/src/hooks/useSystemInfo.ts @@ -24,7 +24,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