Skip to content

Commit

Permalink
chore(feature flag): rewrite check feature flags helper
Browse files Browse the repository at this point in the history
  • Loading branch information
natashatikhonova committed Aug 30, 2023
1 parent 8dfe8ef commit e4f981d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions next-tavla/src/Shared/utils/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { Feature } from 'types/featureFlag'
import fetch from 'node-fetch'

export async function checkFeatureFlags(feature: Feature): Promise<boolean> {
const baseUrl =
process.env.NODE_ENV === 'production'
? process.env.NEXT_PUBLIC_DOMAIN
: 'http://localhost:3000'
const response = await fetch(baseUrl + '/api/featureFlags')
const data = (await response.json()) as string[]
return data.includes(feature)
export function checkFeatureFlags(feature: Feature) {
if (!process.env.ENABLED_FEATURES) return false
const enabledFeatures = JSON.parse(process.env.ENABLED_FEATURES)

return enabledFeatures.includes(feature)
}

0 comments on commit e4f981d

Please sign in to comment.