Skip to content

Commit ca7dc79

Browse files
committed
apparently, prod ignores redirects or process env
1 parent 29c50ee commit ca7dc79

File tree

10 files changed

+39
-27
lines changed

10 files changed

+39
-27
lines changed

website/next.config.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,6 @@ const nextConfig = {
3131
ignoreDuringBuilds: true,
3232
},
3333
async redirects() {
34-
if (process.env.BYE === "true") {
35-
return [
36-
{
37-
source: "/",
38-
destination: "/bye",
39-
permanent: false,
40-
},
41-
{
42-
source: "/dashboard",
43-
destination: "/bye",
44-
permanent: false,
45-
},
46-
{
47-
source: "/chat",
48-
destination: "/bye",
49-
permanent: false,
50-
},
51-
{
52-
source: "/contributors",
53-
destination: "https://ykilcher.com/oa-contributors",
54-
permanent: false,
55-
},
56-
];
57-
}
5834
if (process.env.MAINTENANCE_MODE !== "true") {
5935
return [];
6036
}

website/src/hooks/env/BrowserEnv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createContext, useContext } from "react";
22

33
export interface BrowserConfig {
4+
BYE: boolean;
45
ENABLE_CHAT: boolean;
56
ENABLE_DRAFTS_WITH_PLUGINS: boolean;
67
NUM_GENERATED_DRAFTS: number;

website/src/pages/api/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BrowserConfig } from "src/types/Config";
44

55
// don't put sensitive information here
66
const config: BrowserConfig = {
7+
BYE: boolean(process.env.BYE),
78
ENABLE_CHAT: boolean(process.env.ENABLE_CHAT),
89
ENABLE_DRAFTS_WITH_PLUGINS: boolean(process.env.ENABLE_DRAFTS_WITH_PLUGINS),
910
NUM_GENERATED_DRAFTS: Number(process.env.NUM_GENERATED_DRAFTS),

website/src/pages/bye.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Image from "next/image";
2+
import Link from "next/link";
23
import { Container } from "src/components/Container";
34
export { getStaticProps } from "src/lib/defaultServerSideProps";
45

@@ -20,7 +21,7 @@ const ByePage = () => {
2021
<h2 className="text-2xl font-bold mt-4 mb-2">Links:</h2>
2122
<ul className="text-2xl list-none text-blue-500">
2223
<li>
23-
<a href="/contributors">List of contributors</a>
24+
<Link href="/contributors">List of contributors</Link>
2425
</li>
2526
<li>
2627
<a href="https://ykilcher.com/oa-paper">Paper</a>

website/src/pages/chat/[id].tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import { get } from "src/lib/api";
88
import { ModelInfo, PluginEntry } from "src/types/Chat";
99
export { getServerSideProps } from "src/lib/defaultServerSideProps";
1010
import useSWRImmutable from "swr/immutable";
11+
import { useBrowserConfig } from "src/hooks/env/BrowserEnv";
1112

1213
const Chat = () => {
13-
const { query } = useRouter();
14+
const { BYE } = useBrowserConfig();
15+
const router = useRouter();
16+
const { query } = router;
1417
const id = query.id as string;
1518
const { t } = useTranslation(["common", "chat"]);
1619
const { data: modelInfos } = useSWRImmutable<ModelInfo[]>("/api/chat/models", get, {
@@ -20,6 +23,11 @@ const Chat = () => {
2023
keepPreviousData: true,
2124
});
2225

26+
if (BYE) {
27+
router.push("/bye");
28+
return null;
29+
}
30+
2331
return (
2432
<>
2533
<Head>

website/src/pages/contributors.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useRouter } from "next/router";
2+
3+
const ContributorsPage = () => {
4+
const router = useRouter();
5+
router.push("https://ykilcher.com/oa-contributors");
6+
return null;
7+
};
8+
9+
export default ContributorsPage;

website/src/pages/dashboard.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import { useBrowserConfig } from "src/hooks/env/BrowserEnv";
1414
import { useCurrentLocale } from "src/hooks/locale/useCurrentLocale";
1515
import { API_ROUTES } from "src/lib/routes";
1616
import useSWR from "swr";
17+
import { useRouter } from "next/router";
1718

1819
const Dashboard = () => {
1920
const { t } = useTranslation(["dashboard", "common", "tasks"]);
20-
const { ENABLE_CHAT } = useBrowserConfig();
21+
const { ENABLE_CHAT, BYE } = useBrowserConfig();
22+
const router = useRouter();
2123
const lang = useCurrentLocale();
2224
const { data } = useSWR<AvailableTasks>(API_ROUTES.AVAILABLE_TASK({ lang }), get, {
2325
refreshInterval: 2 * 60 * 1000, //2 minutes
@@ -55,6 +57,11 @@ const Dashboard = () => {
5557
},
5658
};
5759

60+
if (BYE) {
61+
router.push("/bye");
62+
return null;
63+
}
64+
5865
return (
5966
<>
6067
<Head>

website/src/pages/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { CallToAction } from "src/components/CallToAction";
88
import { Faq } from "src/components/Faq";
99
import { Hero } from "src/components/Hero";
1010
export { getDefaultServerSideProps as getStaticProps } from "src/lib/defaultServerSideProps";
11+
import { useBrowserConfig } from "src/hooks/env/BrowserEnv";
1112

1213
const Home = () => {
14+
const { BYE } = useBrowserConfig();
1315
const router = useRouter();
1416
const { status } = useSession();
1517
const { t } = useTranslation();
@@ -19,6 +21,11 @@ const Home = () => {
1921
}
2022
}, [router, status]);
2123

24+
if (BYE) {
25+
router.push("/bye");
26+
return null;
27+
}
28+
2229
return (
2330
<>
2431
<Head>

website/src/types/Config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface BrowserConfig {
2+
BYE: boolean;
23
ENABLE_CHAT: boolean;
34
ENABLE_DRAFTS_WITH_PLUGINS: boolean; // Whether draft messages should be generated if plugins are in use
45
NUM_GENERATED_DRAFTS: number;

website/types/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ declare global {
99
ADMIN_USERS: string;
1010
MODERATOR_USERS: string;
1111
INFERENCE_SERVER_HOST: string;
12+
BYE: boolean;
1213
ENABLE_CHAT: boolean;
1314
ENABLE_DRAFTS_WITH_PLUGINS: boolean;
1415
NUM_GENERATED_DRAFTS: number;

0 commit comments

Comments
 (0)