Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-cache attribute for fetch requests to /system/info/public to prevent stale server info #5730

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ConnectionRequired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
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');
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/router/appRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSystemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading