-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs,shared): Improve CLERK_API_URL default value
- Loading branch information
Showing
6 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const DEV_SUFFIXES = [ | ||
'.lcl.dev', | ||
'.lclstage.dev', | ||
'.dev.lclclerk.com', | ||
'.accounts.lclclerk.com', | ||
'.stg.lclclerk.com', | ||
]; | ||
|
||
export const STAGING_SUFFIXES = ['.stg.dev', '.stgstage.dev', 'accountsstage.dev', 'accounts.dev']; | ||
|
||
export const DEV_OR_STAGING_SUFFIXES = [...DEV_SUFFIXES, ...STAGING_SUFFIXES]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DEV_SUFFIXES, STAGING_SUFFIXES } from '../constants'; | ||
import { parsePublishableKey } from '../keys'; | ||
|
||
export const apiUrlFromPublishableKey = (publishableKey: string) => { | ||
const frontendApi = parsePublishableKey(publishableKey)?.frontendApi; | ||
if (DEV_SUFFIXES.some(suffix => frontendApi?.endsWith(suffix))) { | ||
return 'https://api.lclclerk.com'; | ||
} | ||
if (STAGING_SUFFIXES.some(suffix => frontendApi?.endsWith(suffix))) { | ||
return 'https://api.clerkstage.dev'; | ||
} | ||
return 'https://api.clerk.com'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export { apiUrlFromPublishableKey } from './apiUrlFromPublishableKey'; | ||
export * from './createDeferredPromise'; | ||
export { isStaging } from './instance'; | ||
export { logErrorInDevMode } from './logErrorInDevMode'; | ||
export { noop } from './noop'; | ||
export * from './runtimeEnvironment'; | ||
export * from './runWithExponentialBackOff'; | ||
export { logErrorInDevMode } from './logErrorInDevMode'; | ||
export * from './runtimeEnvironment'; |