From 84d06348e539213eb7084fe058e174cf5f8e6b70 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 1 Dec 2023 17:06:06 +0100 Subject: [PATCH 1/4] move config --- www/.gitignore | 2 ++ www/app/lib/edgeConfig.ts | 14 +------------- www/config-template.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 www/config-template.ts diff --git a/www/.gitignore b/www/.gitignore index e52822e0..895fbb29 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -39,3 +39,5 @@ next-env.d.ts # Sentry Auth Token .sentryclirc + +config.ts \ No newline at end of file diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index a15f871e..bec5bb58 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -1,18 +1,6 @@ import { get } from "@vercel/edge-config"; import { isDevelopment } from "./utils"; - -const localConfig = { - features: { - requireLogin: false, - privacy: true, - browse: false, - sendToZulip: true, - }, - api_url: "http://127.0.0.1:1250", - websocket_url: "ws://127.0.0.1:1250", - auth_callback_url: "http://localhost:3000/auth-callback", - zulip_streams: "https://d3ow1y42gqfmk.cloudfront.net", -}; +import { localConfig } from "../../config"; type EdgeConfig = { [domainWithDash: string]: { diff --git a/www/config-template.ts b/www/config-template.ts new file mode 100644 index 00000000..6f0cf194 --- /dev/null +++ b/www/config-template.ts @@ -0,0 +1,12 @@ +export const localConfig = { + features: { + requireLogin: true, + privacy: true, + browse: true, + sendToZulip: true, + }, + api_url: "http://127.0.0.1:1250", + websocket_url: "ws://127.0.0.1:1250", + auth_callback_url: "http://localhost:3000/auth-callback", + zulip_streams: "", // Find the value on zulip +}; From 4869e760a8810c7c912b83bdbb9855744caf529d Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 1 Dec 2023 17:06:59 +0100 Subject: [PATCH 2/4] fix readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fc8c81b..48ce63a9 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,11 @@ FIEF_URL=https://auth.reflector-ui.dev/reflector-local FIEF_CLIENT_ID=s03 FIEF_CLIENT_SECRET= -EDGE_CONFIG= +EDGE_CONFIG= (optional) ``` +Then copy config-template.ts to a new file called config.ts, this is where you will configure the features or your local project. + ### Run the Application To run the application in development mode, run: From c4557bb9e2c055104a3bfc10951a0cdd94593fd9 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 14 Dec 2023 16:21:59 +0100 Subject: [PATCH 3/4] fix non-dev --- www/app/lib/edgeConfig.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index bec5bb58..d6a71738 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -1,6 +1,5 @@ import { get } from "@vercel/edge-config"; import { isDevelopment } from "./utils"; -import { localConfig } from "../../config"; type EdgeConfig = { [domainWithDash: string]: { @@ -32,7 +31,7 @@ export function edgeDomainToKey(domain: string) { // get edge config server-side (prefer DomainContext when available), domain is the hostname export async function getConfig(domain: string) { if (isDevelopment()) { - return localConfig; + return require("../../config").localConfig; } let config = await get(edgeDomainToKey(domain)); From c693857dcc32dc4ea53cafd14dd6952edfe05931 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 14 Dec 2023 16:34:41 +0100 Subject: [PATCH 4/4] fix non-dev --- www/app/lib/edgeConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index d6a71738..0468200e 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -30,7 +30,7 @@ export function edgeDomainToKey(domain: string) { // get edge config server-side (prefer DomainContext when available), domain is the hostname export async function getConfig(domain: string) { - if (isDevelopment()) { + if (process.env.NEXT_PUBLIC_ENV === "development") { return require("../../config").localConfig; }