diff --git a/src/renderer/api/jellyfin.api.ts b/src/renderer/api/jellyfin.api.ts index 37a307304..9f8b2faf7 100644 --- a/src/renderer/api/jellyfin.api.ts +++ b/src/renderer/api/jellyfin.api.ts @@ -78,11 +78,15 @@ import { ServerListItem, ServerType } from '/@/renderer/types'; import { parseSearchParams } from '/@/renderer/utils'; import packageJson from '../../../package.json'; +const IGNORE_CORS = localStorage.getItem('IGNORE_CORS') === 'true'; + const getCommaDelimitedString = (value: string[]) => { return value.join(','); }; -const api = ky.create({}); +const api = ky.create({ + mode: IGNORE_CORS ? 'no-cors' : undefined, +}); const authenticate = async ( url: string, diff --git a/src/renderer/api/navidrome.api.ts b/src/renderer/api/navidrome.api.ts index 0b9703577..bd19bbfe3 100644 --- a/src/renderer/api/navidrome.api.ts +++ b/src/renderer/api/navidrome.api.ts @@ -88,6 +88,8 @@ import { ServerListItem, ServerType } from '/@/renderer/types'; import { parseSearchParams } from '/@/renderer/utils'; import { subsonicApi } from '/@/renderer/api/subsonic.api'; +const IGNORE_CORS = localStorage.getItem('IGNORE_CORS') === 'true'; + const api = ky.create({ hooks: { afterResponse: [ @@ -122,6 +124,7 @@ const api = ky.create({ }, ], }, + mode: IGNORE_CORS ? 'no-cors' : undefined, }); const authenticate = async ( diff --git a/src/renderer/api/subsonic.api.ts b/src/renderer/api/subsonic.api.ts index 8c441bf6c..575e4b1f1 100644 --- a/src/renderer/api/subsonic.api.ts +++ b/src/renderer/api/subsonic.api.ts @@ -52,6 +52,8 @@ import { import { toast } from '/@/renderer/components/toast'; import { nanoid } from 'nanoid/non-secure'; +const IGNORE_CORS = localStorage.getItem('IGNORE_CORS') === 'true'; + const getCoverArtUrl = (args: { baseUrl: string; coverArtId: string; @@ -93,6 +95,7 @@ const api = ky.create({ }, ], }, + mode: IGNORE_CORS ? 'no-cors' : undefined, }); const getDefaultParams = (server: ServerListItem | null) => { diff --git a/src/renderer/features/servers/components/server-list.tsx b/src/renderer/features/servers/components/server-list.tsx index 56c641d42..ebc10f0eb 100644 --- a/src/renderer/features/servers/components/server-list.tsx +++ b/src/renderer/features/servers/components/server-list.tsx @@ -1,5 +1,6 @@ -import { Group } from '@mantine/core'; -import { Accordion, Button, ContextModalVars } from '/@/renderer/components'; +import { Group, Stack } from '@mantine/core'; +import { Accordion, Button, ContextModalVars, Switch } from '/@/renderer/components'; +import { useLocalStorage } from '@mantine/hooks'; import { openContextModal } from '@mantine/modals'; import { RiAddFill, RiServerFill } from 'react-icons/ri'; import { AddServerForm } from '/@/renderer/features/servers/components/add-server-form'; @@ -22,6 +23,11 @@ export const ServerList = () => { }); }; + const [ignoreCORS, setIgnoreCORS] = useLocalStorage({ + defaultValue: 'false', + key: 'ignore_cors', + }); + return ( <> { Add server - - {serverListQuery?.map((s) => ( - - }> - - {titleCase(s.type)} - {s.name} - - - - - - - ))} - + + + {serverListQuery?.map((s) => ( + + }> + + {titleCase(s.type)} - {s.name} + + + + + + + ))} + + + setIgnoreCORS(String(e.currentTarget.checked))} + /> + + ); };