Skip to content

Commit 9672d17

Browse files
committed
fix: init clerk only on cloud (#3028)
### TL;DR Conditionally initialize Clerk authentication based on app type ### What changed? Modified the `auth.ts` file to only initialize the Clerk authentication client when the application is running in cloud mode. When not in cloud mode, the clerk variable is set to null (cast as Clerk type). ### How to test? 1. Verify that authentication works correctly in cloud environments 2. Confirm that the application doesn't attempt to initialize Clerk in non-cloud environments 3. Check that no authentication errors occur in either environment ### Why make this change? This change prevents unnecessary Clerk initialization in non-cloud environments where authentication might be handled differently or not needed. This improves efficiency and prevents potential errors from attempting to use Clerk with invalid or missing credentials in development or other non-cloud contexts.
1 parent 67584f2 commit 9672d17

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

frontend/src/lib/auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { Clerk } from "@clerk/clerk-js";
22
import { cloudEnv } from "./env";
33

4-
export const clerk = new Clerk(cloudEnv().VITE_APP_CLERK_PUBLISHABLE_KEY);
4+
export const clerk =
5+
__APP_TYPE__ === "cloud"
6+
? new Clerk(cloudEnv().VITE_APP_CLERK_PUBLISHABLE_KEY)
7+
: (null as unknown as Clerk);

0 commit comments

Comments
 (0)