Load android requests at root
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import { timeout } from '$lib/misc';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
const originalFetch = window.fetch;
|
||||
const corsProxyUrl: string = 'http://localhost:3000/';
|
||||
|
||||
let nodejsStarted = false;
|
||||
|
||||
function needsProxying(target: string): boolean {
|
||||
if (!target.startsWith('http')) return false;
|
||||
return true;
|
||||
@@ -15,19 +12,6 @@ export const androidFetch = async (
|
||||
requestInput: string | URL | Request,
|
||||
requestOptions?: RequestInit
|
||||
): Promise<Response> => {
|
||||
// On initial request pause until OPTIONS request passes on local proxy, only reliable way
|
||||
// to ensure proxy is working on android.
|
||||
if (!nodejsStarted) {
|
||||
let testResp: Response | undefined = undefined;
|
||||
while (typeof testResp === 'undefined' || !testResp.ok) {
|
||||
try {
|
||||
testResp = await originalFetch(corsProxyUrl, { method: 'OPTIONS' });
|
||||
} catch (error) {}
|
||||
await timeout(100);
|
||||
}
|
||||
nodejsStarted = true;
|
||||
}
|
||||
|
||||
const uri = requestInput instanceof Request ? requestInput.url : requestInput.toString();
|
||||
|
||||
if (needsProxying(uri)) {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { navigating, page } from '$app/stores';
|
||||
import '$lib/android/http/androidRequests';
|
||||
import colorTheme, { convertToHexColorCode } from '$lib/android/plugins/colorTheme';
|
||||
import { getFeed } from '$lib/api/index';
|
||||
import type { Notification } from '$lib/api/model';
|
||||
|
||||
@@ -8,6 +8,7 @@ import { initI18n } from '$lib/i18n';
|
||||
import { getPages } from '$lib/navPages';
|
||||
import { authStore, interfaceDefaultPage, isAndroidTvStore } from '$lib/store';
|
||||
import { get } from 'svelte/store';
|
||||
import '$lib/android/http/androidRequests';
|
||||
|
||||
export const ssr = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user