Skip to content

Commit 598a699

Browse files
committed
fix(nuxt): support NUXT_PUBLIC_CLERK_JS_URL and NUXT_PUBLIC_CLERK_UI_URL env vars
Nuxt converts camelCase runtime config keys to env var names by inserting underscores before uppercase letters. The keys clerkJSUrl/clerkUiUrl were being converted to NUXT_PUBLIC_CLERK_CLERK_J_S_URL which is not what users expect. Renamed the runtime config keys to jsUrl/uiUrl so they correctly map to NUXT_PUBLIC_CLERK_JS_URL and NUXT_PUBLIC_CLERK_UI_URL, then map them back to clerkJSUrl/clerkUiUrl when passing to the Vue plugin. This allows users to set these values via environment variables using the expected naming convention.
1 parent 71023f2 commit 598a699

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

packages/nuxt/src/global.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ declare module 'nuxt/schema' {
1616
};
1717
}
1818
interface PublicRuntimeConfig {
19-
clerk: PluginOptions;
19+
clerk: Omit<PluginOptions, 'clerkJSUrl' | 'clerkUiUrl'> & {
20+
/**
21+
* The URL that `@clerk/clerk-js` should be hot-loaded from.
22+
* Supports NUXT_PUBLIC_CLERK_JS_URL env var.
23+
*/
24+
jsUrl?: string;
25+
/**
26+
* The URL that `@clerk/ui` should be hot-loaded from.
27+
* Supports NUXT_PUBLIC_CLERK_UI_URL env var.
28+
*/
29+
uiUrl?: string;
30+
};
2031
}
2132
}
2233

packages/nuxt/src/module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ export default defineNuxtModule<ModuleOptions>({
6464
signUpForceRedirectUrl: options.signUpForceRedirectUrl,
6565
signUpUrl: options.signUpUrl,
6666
domain: options.domain,
67-
clerkJSUrl: options.clerkJSUrl,
68-
clerkUiUrl: options.clerkUiUrl,
67+
// Using jsUrl/uiUrl instead of clerkJSUrl/clerkUiUrl to support
68+
// NUXT_PUBLIC_CLERK_JS_URL and NUXT_PUBLIC_CLERK_UI_URL env vars.
69+
jsUrl: options.clerkJSUrl,
70+
uiUrl: options.clerkUiUrl,
6971
clerkJSVariant: options.clerkJSVariant,
7072
clerkJSVersion: options.clerkJSVersion,
7173
isSatellite: options.isSatellite,

packages/nuxt/src/runtime/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ export default defineNuxtPlugin(nuxtApp => {
1717
}
1818

1919
const runtimeConfig = useRuntimeConfig();
20+
const clerkConfig = runtimeConfig.public.clerk ?? {};
2021

2122
nuxtApp.vueApp.use(clerkPlugin as any, {
22-
...(runtimeConfig.public.clerk ?? {}),
23+
...clerkConfig,
24+
// Map jsUrl/uiUrl to clerkJSUrl/clerkUiUrl as expected by the Vue plugin
25+
clerkJSUrl: clerkConfig.jsUrl,
26+
clerkUiUrl: clerkConfig.uiUrl,
2327
sdkMetadata: {
2428
name: PACKAGE_NAME,
2529
version: PACKAGE_VERSION,

0 commit comments

Comments
 (0)