fix(builder): 🐛 Add public env var in runtime config
This commit is contained in:
@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
|
||||
import { Text, HStack } from '@chakra-ui/react'
|
||||
import { SearchableDropdown } from '../../../shared/SearchableDropdown'
|
||||
import { isEmpty } from 'utils'
|
||||
import getConfig from 'next/config'
|
||||
|
||||
type FontSelectorProps = {
|
||||
activeFont?: string
|
||||
@ -20,9 +21,12 @@ export const FontSelector = ({
|
||||
}, [])
|
||||
|
||||
const fetchPopularFonts = async () => {
|
||||
if (isEmpty(process.env.NEXT_PUBLIC_GOOGLE_API_KEY)) return []
|
||||
const {
|
||||
publicRuntimeConfig: { NEXT_PUBLIC_GOOGLE_API_KEY },
|
||||
} = getConfig()
|
||||
if (isEmpty(NEXT_PUBLIC_GOOGLE_API_KEY)) return []
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/webfonts/v1/webfonts?key=${process.env.NEXT_PUBLIC_GOOGLE_API_KEY}&sort=popularity`
|
||||
`https://www.googleapis.com/webfonts/v1/webfonts?key=${NEXT_PUBLIC_GOOGLE_API_KEY}&sort=popularity`
|
||||
)
|
||||
return (await response.json()).items.map(
|
||||
(item: { family: string }) => item.family
|
||||
|
Reference in New Issue
Block a user