2
0

Revert "fix(docker): 🐛 Runtime public environment"

This reverts commit e03fe9f7d9.
This commit is contained in:
Baptiste Arnaud
2022-06-22 07:21:02 +02:00
parent e03fe9f7d9
commit 3e47b37c2e
54 changed files with 164 additions and 349 deletions

View File

@ -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,
})