-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically reload when API call is redirected
- Loading branch information
Showing
4 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
export const fetch = globalThis.fetch; | ||
import * as connection from "../connection" | ||
|
||
export const fetch = async ( | ||
input: RequestInfo | URL, | ||
options?: RequestInit, | ||
): Promise<Response> => { | ||
const response = await globalThis.fetch(input, options); | ||
|
||
const originalHost = new URL(input instanceof Request ? input.url : input).host | ||
Check warning on line 9 in packages/loot-core/src/platform/server/fetch/index.web.ts GitHub Actions / lint
|
||
|
||
if (response.redirected && (new URL(response.url)).host !== originalHost) { | ||
connection.send("api-fetch-redirected") | ||
} | ||
|
||
return response | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters