Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): read the turnstile key at runtime

Andreja0d8cbb080c7
diff --git a/apps/web/src/components/auth/turnstile-site-key.ts b/apps/web/src/components/auth/turnstile-site-key.ts
new file mode 100644
index 000000000..da758de93
--- /dev/null
+++ b/apps/web/src/components/auth/turnstile-site-key.ts
@@ -0,0 +1,7 @@
+const publicEnv: { turnstileSiteKey: string | undefined } = {
+ turnstileSiteKey: import.meta.env.VITE_TURNSTILE_SITE_KEY,
+};
+
+export function getTurnstileSiteKey() {
+ return publicEnv.turnstileSiteKey || undefined;
+}
diff --git a/apps/web/src/components/auth/use-auth-captcha.ts b/apps/web/src/components/auth/use-auth-captcha.ts
index 44efbe56e..7e761ca0c 100644
--- a/apps/web/src/components/auth/use-auth-captcha.ts
+++ b/apps/web/src/components/auth/use-auth-captcha.ts
@@ -1,7 +1,8 @@
import { useCallback, useState } from "react";
+import { getTurnstileSiteKey } from "./turnstile-site-key";
export function useAuthCaptcha() {
- const siteKey = import.meta.env.VITE_TURNSTILE_SITE_KEY as string | undefined;
+ const siteKey = getTurnstileSiteKey();
const [token, setToken] = useState<string | null>(null);
const [key, setKey] = useState(0);
const clear = useCallback(() => setToken(null), []);