@@ -3,30 +3,34 @@ import { apiUrlFromPublishableKey } from '@clerk/shared/apiUrlFromPublishableKey
33import { handleValueOrFn } from '@clerk/shared/handleValueOrFn' ;
44import { isDevelopmentFromSecretKey } from '@clerk/shared/keys' ;
55import { isHttpOrHttps , isProxyUrlRelative } from '@clerk/shared/proxy' ;
6- import { isTruthy } from '@clerk/shared/underscore' ;
76
87import { errorThrower } from '../utils' ;
98import { getEnvVariable , getPublicEnvVariables } from '../utils/env' ;
9+ import {
10+ CLERK_JWT_KEY ,
11+ DOMAIN ,
12+ IS_SATELLITE ,
13+ PROXY_URL ,
14+ PUBLISHABLE_KEY ,
15+ SECRET_KEY ,
16+ SIGN_IN_URL ,
17+ SIGN_UP_URL ,
18+ } from './constants' ;
1019import type { LoaderOptions } from './types' ;
1120import { patchRequest } from './utils' ;
1221
1322export const loadOptions = ( request : Request , overrides : LoaderOptions = { } ) => {
1423 const clerkRequest = createClerkRequest ( patchRequest ( request ) ) ;
1524
16- const secretKey = overrides . secretKey || overrides . secretKey || getEnvVariable ( 'CLERK_SECRET_KEY' ) ;
17- const publishableKey = overrides . publishableKey || getPublicEnvVariables ( ) . publishableKey ;
18- const jwtKey = overrides . jwtKey || getEnvVariable ( ' CLERK_JWT_KEY' ) ;
25+ const secretKey = overrides . secretKey || SECRET_KEY ;
26+ const publishableKey = overrides . publishableKey || PUBLISHABLE_KEY ;
27+ const jwtKey = overrides . jwtKey || CLERK_JWT_KEY ;
1928 const apiUrl = getEnvVariable ( 'CLERK_API_URL' ) || apiUrlFromPublishableKey ( publishableKey ) ;
20- const domain = handleValueOrFn ( overrides . domain , new URL ( request . url ) ) || getPublicEnvVariables ( ) . domain ;
21- const isSatellite =
22- handleValueOrFn ( overrides . isSatellite , new URL ( request . url ) ) || isTruthy ( getPublicEnvVariables ( ) . isSatellite ) ;
23- const relativeOrAbsoluteProxyUrl = handleValueOrFn (
24- overrides ?. proxyUrl ,
25- clerkRequest . clerkUrl ,
26- getPublicEnvVariables ( ) . proxyUrl ,
27- ) ;
28- const signInUrl = overrides . signInUrl || getPublicEnvVariables ( ) . signInUrl ;
29- const signUpUrl = overrides . signUpUrl || getPublicEnvVariables ( ) . signUpUrl ;
29+ const domain = handleValueOrFn ( overrides . domain , new URL ( request . url ) ) || DOMAIN ;
30+ const isSatellite = handleValueOrFn ( overrides . isSatellite , new URL ( request . url ) ) || IS_SATELLITE ;
31+ const relativeOrAbsoluteProxyUrl = handleValueOrFn ( overrides ?. proxyUrl , clerkRequest . clerkUrl , PROXY_URL ) ;
32+ const signInUrl = overrides . signInUrl || SIGN_IN_URL ;
33+ const signUpUrl = overrides . signUpUrl || SIGN_UP_URL ;
3034 const afterSignInUrl = overrides . afterSignInUrl || getPublicEnvVariables ( ) . afterSignInUrl ;
3135 const afterSignUpUrl = overrides . afterSignUpUrl || getPublicEnvVariables ( ) . afterSignUpUrl ;
3236
0 commit comments