A local-first personal finance app
Revert "Reload on all redirects to handle Cloudflare Access auth expiration (…" (#4835)
Roger Goldfinger62ab6a12e818
diff --git a/packages/loot-core/src/platform/server/fetch/index.ts b/packages/loot-core/src/platform/server/fetch/index.tsindex f357473b69..f93196b0f5 100644--- a/packages/loot-core/src/platform/server/fetch/index.ts+++ b/packages/loot-core/src/platform/server/fetch/index.ts@@ -2,18 +2,17 @@ import * as connection from '../connection';export const fetch = async (input: RequestInfo | URL,- options: RequestInit = {},+ options?: RequestInit,): Promise<Response> => {- // Set redirect to manual so that we can detect and respond to redirects.- if (!options.redirect) options.redirect = 'manual';-const response = await globalThis.fetch(input, options);- // Authentication proxies redirect when authentication has expired. In this case,- // we want to fully reload and yeild control from the service worker back to the server.- if (response.type === 'opaqueredirect') {+ // Detect if the API query has been redirected to a different origin. This may indicate that the+ // request has been intercepted by an authentication proxy+ const originalUrl = new URL(input instanceof Request ? input.url : input);+ const responseUrl = new URL(response.url);+ if (response.redirected && responseUrl.host !== originalUrl.host) {connection.send('api-fetch-redirected');- throw new Error(`API request redirected`);+ throw new Error(`API request redirected to ${responseUrl.host}`);}return response;diff --git a/upcoming-release-notes/4706.md b/upcoming-release-notes/4706.mddeleted file mode 100644index 6e65b7b7c6..0000000000--- a/upcoming-release-notes/4706.md+++ /dev/null@@ -1,6 +0,0 @@-----category: Bugfix-authors: [rgoldfinger]------Reload on all redirects to handle Cloudflare Access expiration. This fixes issue #4422