Browse Source

normal routing instead of hash

Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
pull/143/head
mrjvs 3 years ago
parent
commit
c441d63074
  1. 1
      src/backend/providers/m4ufree.ts
  2. 16
      src/index.tsx
  3. 3
      src/setup/config.ts

1
src/backend/providers/m4ufree.ts

@ -29,6 +29,7 @@ registerProvider({ @@ -29,6 +29,7 @@ registerProvider({
id: "m4ufree",
displayName: "m4ufree",
rank: -1,
disabled: true, // Disables because the redirector URLs it returns will throw 404 / 403 depending on if you view it in the browser or fetch it respectively. It just does not work.
type: [MWMediaType.MOVIE, MWMediaType.SERIES],
async scrape({ media, progress, type, episode: episodeId, season: seasonId }) {

16
src/index.tsx

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import React, { Suspense } from "react";
import React, { ReactNode, Suspense } from "react";
import ReactDOM from "react-dom";
import { HashRouter } from "react-router-dom";
import { BrowserRouter, HashRouter } from "react-router-dom";
import { ErrorBoundary } from "@/components/layout/ErrorBoundary";
import { conf } from "@/setup/config";
@ -42,14 +42,22 @@ const LazyLoadedApp = React.lazy(async () => { @@ -42,14 +42,22 @@ const LazyLoadedApp = React.lazy(async () => {
};
});
function TheRouter(props: { children: ReactNode }) {
const normalRouter = conf().NORMAL_ROUTER;
if (normalRouter)
return <BrowserRouter children={props.children} />
return <HashRouter children={props.children} />
}
ReactDOM.render(
<React.StrictMode>
<ErrorBoundary>
<HashRouter>
<TheRouter>
<Suspense fallback="">
<LazyLoadedApp />
</Suspense>
</HashRouter>
</TheRouter>
</ErrorBoundary>
</React.StrictMode>,
document.getElementById("root")

3
src/setup/config.ts

@ -7,6 +7,7 @@ interface Config { @@ -7,6 +7,7 @@ interface Config {
OMDB_API_KEY: string;
TMDB_API_KEY: string;
CORS_PROXY_URL: string;
NORMAL_ROUTER: boolean;
}
export interface RuntimeConfig extends Config {
@ -20,6 +21,7 @@ const env: Record<keyof Config, undefined | string> = { @@ -20,6 +21,7 @@ const env: Record<keyof Config, undefined | string> = {
GITHUB_LINK: undefined,
DISCORD_LINK: undefined,
CORS_PROXY_URL: import.meta.env.VITE_CORS_PROXY_URL,
NORMAL_ROUTER: import.meta.env.VITE_NORMAL_ROUTER,
};
const alerts = [] as string[];
@ -51,5 +53,6 @@ export function conf(): RuntimeConfig { @@ -51,5 +53,6 @@ export function conf(): RuntimeConfig {
TMDB_API_KEY: getKey("TMDB_API_KEY"),
BASE_PROXY_URL: getKey("CORS_PROXY_URL"),
CORS_PROXY_URL: `${getKey("CORS_PROXY_URL")}/?destination=`,
NORMAL_ROUTER: (getKey("NORMAL_ROUTER") ?? "false") === "true",
};
}

Loading…
Cancel
Save