-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(feature flag): rewrite check feature flags helper
- Loading branch information
1 parent
8dfe8ef
commit e4f981d
Showing
1 changed file
with
5 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |