mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
✨ feat: use env to control clerk allow origin feature (#9863)
feat: use clerk allow origin feature
This commit is contained in:
parent
55c1149d95
commit
490fee002e
2 changed files with 15 additions and 0 deletions
|
|
@ -256,6 +256,9 @@ OPENAI_API_KEY=sk-xxxxxxxxx
|
|||
# you need to config the clerk webhook secret key if you want to use the clerk with database
|
||||
#CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# Clear allow origin https://clerk.com/docs/guides/dashboard/dns-domains/satellite-domains
|
||||
# Authentication across different domains , use,to splite different origin
|
||||
# NEXT_PUBLIC_CLERK_AUTH_ALLOW_ORIGINS='https://market.lobehub.com,https://lobehub.com'
|
||||
|
||||
# NextAuth related configurations
|
||||
# NEXT_PUBLIC_ENABLE_NEXT_AUTH=1
|
||||
|
|
|
|||
|
|
@ -30,6 +30,17 @@ const Clerk = memo(({ children }: PropsWithChildren) => {
|
|||
});
|
||||
}, [count, setCount, isPending, startTransition]);
|
||||
|
||||
const allowedRedirectOrigins = useMemo(() => {
|
||||
const rawOrigins = process.env.NEXT_PUBLIC_CLERK_AUTH_ALLOW_ORIGINS;
|
||||
if (!rawOrigins) return undefined;
|
||||
|
||||
const origins = rawOrigins
|
||||
.split(',')
|
||||
.map((origin) => origin.trim())
|
||||
.filter(Boolean);
|
||||
return origins.length ? origins : undefined;
|
||||
}, []);
|
||||
|
||||
const updatedAppearance = useMemo(
|
||||
() => ({
|
||||
...appearance,
|
||||
|
|
@ -43,6 +54,7 @@ const Clerk = memo(({ children }: PropsWithChildren) => {
|
|||
|
||||
return (
|
||||
<ClerkProvider
|
||||
allowedRedirectOrigins={allowedRedirectOrigins}
|
||||
appearance={updatedAppearance}
|
||||
localization={localization}
|
||||
signUpUrl={!enableClerkSignUp ? '/login' : '/signup'} // Redirect sign-up to sign-in if disabled
|
||||
|
|
|
|||
Loading…
Reference in a new issue