Revert "fix(docker): 🐛 Runtime public environment"
This reverts commit e03fe9f7d9
.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Plan, User } from 'db'
|
||||
import { loadStripe } from '@stripe/stripe-js/pure'
|
||||
import { env, isDefined, isEmpty, sendRequest } from 'utils'
|
||||
import { isDefined, isEmpty, sendRequest } from 'utils'
|
||||
import getConfig from 'next/config'
|
||||
|
||||
type Props = {
|
||||
user: User
|
||||
@ -39,7 +40,10 @@ const redirectToCheckout = async ({
|
||||
plan,
|
||||
workspaceId,
|
||||
}: Omit<Props, 'customerId'>) => {
|
||||
if (isEmpty(env('STRIPE_PUBLIC_KEY')))
|
||||
const {
|
||||
publicRuntimeConfig: { NEXT_PUBLIC_STRIPE_PUBLIC_KEY },
|
||||
} = getConfig()
|
||||
if (isEmpty(NEXT_PUBLIC_STRIPE_PUBLIC_KEY))
|
||||
throw new Error('NEXT_PUBLIC_STRIPE_PUBLIC_KEY is missing in env')
|
||||
const { data, error } = await sendRequest<{ sessionId: string }>({
|
||||
method: 'POST',
|
||||
@ -53,7 +57,7 @@ const redirectToCheckout = async ({
|
||||
},
|
||||
})
|
||||
if (error || !data) return
|
||||
const stripe = await loadStripe(env('STRIPE_PUBLIC_KEY') as string)
|
||||
const stripe = await loadStripe(NEXT_PUBLIC_STRIPE_PUBLIC_KEY)
|
||||
await stripe?.redirectToCheckout({
|
||||
sessionId: data?.sessionId,
|
||||
})
|
||||
|
Reference in New Issue
Block a user