File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1- import "@vercel/flags/ next";
1+ import { NextResponse } from " next/server ";
22
33export async function GET ( ) {
44 const isEnabled = unstable_flag ( "WeatherWidgetEnabled" , false ) ;
5- return new Response ( JSON . stringify ( { isEnabled } ) , {
6- headers : { "Content-Type" : "application/json" } ,
7- } ) ;
5+ return NextResponse . json ( { isEnabled } ) ;
86}
7+
98function unstable_flag ( flagName : string , defaultValue : boolean ) : boolean {
109 // Simulate a feature flag check. In a real-world scenario, this might query a database or an external service.
1110 const featureFlags : Record < string , boolean > = {
1211 WeatherWidgetEnabled : true , // Example flag
1312 } ;
1413
14+ if ( ! ( flagName in featureFlags ) ) {
15+ console . warn ( `Feature flag "${ flagName } " not found. Using default value.` ) ;
16+ }
17+
1518 return featureFlags [ flagName ] ?? defaultValue ;
1619}
You can’t perform that action at this time.
0 commit comments