Revert last canary flag PR and use a better method (#5535)
* Revert "Implement Labrinth Canary API flag (#5531)"
This reverts commit 3b21944a75.
* Use Labrinth-Canary header instead of cookie for API canary
* prepr
* fix rebase
This commit is contained in:
@@ -2,9 +2,7 @@ import {
|
||||
type AbstractFeature,
|
||||
type AuthConfig,
|
||||
AuthFeature,
|
||||
CanaryCookieFeature,
|
||||
CircuitBreakerFeature,
|
||||
LABRINTH_CANARY_COOKIE,
|
||||
NodeAuthFeature,
|
||||
nodeAuthState,
|
||||
NuxtCircuitBreakerStorage,
|
||||
@@ -30,11 +28,7 @@ export function createModrinthClient(
|
||||
auth: Ref<{ token: string | undefined }>,
|
||||
config: { apiBaseUrl: string; archonBaseUrl: string; rateLimitKey?: string },
|
||||
): NuxtModrinthClient {
|
||||
const flags = useFeatureFlags()
|
||||
const optionalFeatures = [
|
||||
new CanaryCookieFeature({
|
||||
getCookie: () => (flags.value.labrinthApiCanary ? LABRINTH_CANARY_COOKIE : undefined),
|
||||
}) as AbstractFeature,
|
||||
import.meta.dev ? (new VerboseLoggingFeature() as AbstractFeature) : undefined,
|
||||
].filter(Boolean) as AbstractFeature[]
|
||||
|
||||
|
||||
15
apps/frontend/src/helpers/canary.ts
Normal file
15
apps/frontend/src/helpers/canary.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export const LABRINTH_CANARY_HEADER = 'Labrinth-Canary'
|
||||
export const LABRINTH_CANARY_VALUE = 'always'
|
||||
|
||||
export function withLabrinthCanaryHeader(headers: Record<string, string> = {}) {
|
||||
const flags = useFeatureFlags()
|
||||
|
||||
if (!flags.value.labrinthApiCanary) {
|
||||
return headers
|
||||
}
|
||||
|
||||
return {
|
||||
...headers,
|
||||
[LABRINTH_CANARY_HEADER]: LABRINTH_CANARY_VALUE,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user