mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
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: a0e6da790c
Merged-by: thornbill <thornbill@users.noreply.github.com>
Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
parent
b2d5a67f26
commit
614c9e4481
4 changed files with 4 additions and 4 deletions
|
@ -83,7 +83,7 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
if (firstConnection.State === ConnectionState.ServerSignIn) {
|
if (firstConnection.State === ConnectionState.ServerSignIn) {
|
||||||
// Verify the wizard is complete
|
// Verify the wizard is complete
|
||||||
try {
|
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) {
|
if (!infoResponse.ok) {
|
||||||
throw new Error('Public system info request failed');
|
throw new Error('Public system info request failed');
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ class AppRouter {
|
||||||
if (firstResult) {
|
if (firstResult) {
|
||||||
if (firstResult.State === ConnectionState.ServerSignIn) {
|
if (firstResult.State === ConnectionState.ServerSignIn) {
|
||||||
const url = firstResult.ApiClient.serverAddress() + '/System/Info/Public';
|
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'));
|
if (!response.ok) return Promise.reject(new Error('fetch failed'));
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const getSystemInfoQuery = (
|
||||||
api?: Api
|
api?: Api
|
||||||
) => queryOptions({
|
) => queryOptions({
|
||||||
queryKey: [ 'SystemInfo' ],
|
queryKey: [ 'SystemInfo' ],
|
||||||
queryFn: ({ signal }) => fetchSystemInfo(api, { signal }),
|
queryFn: ({ signal }) => fetchSystemInfo(api, { signal, headers: { 'Cache-Control': 'no-cache' } }),
|
||||||
// Allow for query reuse in legacy javascript.
|
// Allow for query reuse in legacy javascript.
|
||||||
staleTime: 1000, // 1 second
|
staleTime: 1000, // 1 second
|
||||||
enabled: !!api
|
enabled: !!api
|
||||||
|
|
|
@ -52,7 +52,7 @@ export async function serverAddress() {
|
||||||
console.debug('URL candidates:', urls);
|
console.debug('URL candidates:', urls);
|
||||||
|
|
||||||
const promises = urls.map(url => {
|
const promises = urls.map(url => {
|
||||||
return fetch(`${url}/System/Info/Public`)
|
return fetch(`${url}/System/Info/Public`, { cache: 'no-cache' })
|
||||||
.then(async resp => {
|
.then(async resp => {
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue