Skip to content

Commit 2e1124c

Browse files
fix: call /v2/feature_flags/{id} via raw fetch
The endpoint is live in market-api (v2_routes.rs:593) but its handler lacks a `#[utoipa::path]` macro, so it's absent from the regenerated OpenAPI schema. Drop the typed client for this call and use fetch directly — matches the pattern in sfcompute.com's feature-flags provider.
1 parent effb4e6 commit 2e1124c

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/lib/posthog.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,20 @@ export const isFeatureEnabled = async (feature: FeatureFlags) => {
8181
return cachedFlag.value;
8282
}
8383

84-
// Fetch from the v2/feature_flags API
84+
// Fetch from the v2/feature_flags API. Uses raw fetch because the route is
85+
// not exposed on the regenerated `src/schema.ts` (only the admin variant is),
86+
// but it is still served externally per the HAProxy config.
8587
let finalResult = false;
8688
try {
87-
const client = await apiClient(config.auth_token);
88-
const { data, response } = await client.GET(
89-
"/v2/feature_flags/{feature_flag_id}",
90-
{ params: { path: { feature_flag_id: feature } } },
89+
const response = await fetch(
90+
`${config.api_url}/v2/feature_flags/${encodeURIComponent(feature)}`,
91+
{ headers: { Authorization: `Bearer ${config.auth_token}` } },
9192
);
93+
if (response.ok) {
94+
const data = (await response.json()) as { enabled?: boolean };
95+
finalResult = data?.enabled ?? false;
96+
}
9297
// 404 means the flag doesn't exist → treat as disabled (false)
93-
finalResult = response.ok ? (data?.enabled ?? false) : false;
9498
} catch {
9599
// Network or parse error → default to false
96100
}

0 commit comments

Comments
 (0)